Package org.apache.catalina.connector
Class Response
- java.lang.Object
-
- org.apache.catalina.connector.Response
-
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletResponse
,jakarta.servlet.ServletResponse
,HttpResponse
,Response
- Direct Known Subclasses:
PECoyoteResponse
public class Response extends Object implements HttpResponse, jakarta.servlet.http.HttpServletResponse
Wrapper object for the Coyote response.- Version:
- $Revision: 1.22 $ $Date: 2007/05/05 05:32:43 $
- Author:
- Remy Maucherat, Craig R. McClanahan
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
appCommitted
The application commit flag.protected Connector
connector
Associated Catalina connector.protected Context
context
Associated context.protected org.glassfish.grizzly.http.server.Response
coyoteResponse
Coyote response.protected boolean
error
The error flag.protected ResponseFacade
facade
The facade associated with this response.protected SimpleDateFormat
format
The date format we will use for creating date headers.static String
HTTP_RESPONSE_DATE_HEADER
protected boolean
included
The included flag.protected static String
info
Descriptive information about this Response implementation.protected OutputBuffer
outputBuffer
The associated output buffer.protected CoyoteOutputStream
outputStream
The associated output stream.protected org.glassfish.grizzly.http.util.CharChunk
redirectURLCC
Recyclable buffer to hold the redirect URL.protected Request
request
The request with which this response is associated.protected boolean
upgrade
protected org.glassfish.grizzly.http.util.UEncoder
urlEncoder
URL encoder.protected boolean
usingOutputStream
Using output stream flag.protected boolean
usingWriter
Using writer flag.protected CoyoteWriter
writer
The associated writer.-
Fields inherited from interface jakarta.servlet.http.HttpServletResponse
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_FOUND, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addCookie(jakarta.servlet.http.Cookie cookie)
Add the specified Cookie to those that will be included with this Response.void
addDateHeader(String name, long value)
Add the specified date header to the specified value.void
addHeader(String name, String value)
Add the specified header to the specified value.void
addIntHeader(String name, int value)
Add the specified integer header to the specified value.void
addSessionCookieInternal(jakarta.servlet.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding any previousboolean
containsHeader(String name)
Has the specified header been set already in this response?jakarta.servlet.ServletOutputStream
createOutputStream()
Create and return a ServletOutputStream to write the content associated with this Response.protected CoyoteWriter
createWriter(OutputBuffer outbuf)
Create an instance of CoyoteWriterString
encode(String url)
Apply URL Encoding to the given URL without adding session identifier et al associated to this response.String
encodeRedirectURL(String url)
Encode the session identifier associated with this response into the specified redirect URL, if necessary.String
encodeURL(String url)
Encode the session identifier associated with this response into the specified URL, if necessary.void
finishResponse()
Perform whatever actions are required to flush and close the output stream or writer, in a single operation.void
flushBuffer()
Flush the buffer and commit this response.int
getBufferSize()
Return the actual buffer size used for this Response.String
getCharacterEncoding()
Return the character encoding used for this Response.Connector
getConnector()
Return the Connector through which this Request was received.int
getContentCount()
Return the number of bytes actually written to the output stream.int
getContentLength()
Return the content length that was set or calculated for this Response.String
getContentType()
Return the content type that was set or calculated for this response, ornull
if no content type was set.Context
getContext()
Return the Context within which this Request is being processed.protected String
getCookieString(jakarta.servlet.http.Cookie cookie)
Gets the string representation of the given cookie.org.glassfish.grizzly.http.server.Response
getCoyoteResponse()
Get the Coyote response.String
getDetailMessage()
Gets detail error message.String
getHeader(String name)
Return the value for the specified header, ornull
if this header has not been set.Collection<String>
getHeaderNames()
Collection<String>
getHeaders(String name)
boolean
getIncluded()
Return the "processing inside an include" flag.String
getInfo()
Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>
.Locale
getLocale()
Return the Locale assigned to this response.String
getMessage()
Return the error message that was set withsendError()
for this Response.jakarta.servlet.ServletOutputStream
getOutputStream()
Return the servlet output stream associated with this Response.PrintWriter
getReporter()
Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired.Request
getRequest()
Return the Request with which this Response is associated.jakarta.servlet.http.HttpServletResponse
getResponse()
Return theServletResponse
for which this object is the facade.int
getStatus()
Return the HTTP status code associated with this Response.OutputStream
getStream()
Return the output stream associated with this Response.Supplier<Map<String,String>>
getTrailerFields()
PrintWriter
getWriter()
Return the writer associated with this Response.boolean
isAppCommitted()
Application commit flag accessor.boolean
isCommitted()
Has the output of this response already been committed?protected boolean
isEncodeable(String location)
Returntrue
if the specified URL should be encoded with a session identifier.boolean
isError()
Error flag accessor.boolean
isSuspended()
Suspended flag accessor.void
recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.void
removeSessionCookies()
Removes any Set-Cookie response headers whose value contains the string JSESSIONIDvoid
reset()
Clear any content written to the buffer.void
reset(int status, String message)
Reset this response, and specify the values for the HTTP status code and corresponding message.void
resetBuffer()
Reset the data buffer but not any status or header information.void
resetBuffer(boolean resetWriterStreamFlags)
Reset the data buffer and the using Writer/Stream flags but not any status or header information.void
sendAcknowledgement()
Send an acknowledgment of a request.void
sendError(int status)
Send an error response with the specified status and a default message.void
sendError(int status, String message)
Send an error response with the specified status and message.void
sendRedirect(String location)
Sends a temporary redirect to the specified redirect location URL.void
sendRedirect(String location, boolean isTemporary)
Sends a temporary or permanent redirect to the specified redirect location URL.void
setAppCommitted(boolean appCommitted)
Set the application commit flag.void
setBufferSize(int size)
Set the buffer size to be used for this Response.void
setCharacterEncoding(String charset)
Overrides the name of the character encoding used in the body of the request.void
setConnector(Connector connector)
Set the Connector through which this Request was received.void
setContentLength(int length)
Set the content length (in bytes) for this Response.void
setContentLengthLong(long length)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.void
setContentType(String type)
Set the content type for this Response.void
setContext(Context context)
Set the Context within which this Request is being processed.void
setCoyoteResponse(org.glassfish.grizzly.http.server.Response coyoteResponse)
Set the Coyote response.void
setDateHeader(String name, long value)
Set the specified date header to the specified value.void
setDetailMessage(String message)
Sets detail error message.static void
setEnforceScope(boolean enforce)
Set whether or not to enforce scope checking of this object.void
setError()
Set the error flag.void
setHeader(String name, String value)
Set the specified header to the specified value.void
setIncluded(boolean included)
Set the "processing inside an include" flag.void
setIntHeader(String name, int value)
Set the specified integer header to the specified value.void
setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding.void
setRequest(Request request)
Set the Request with which this Response is associated.void
setStatus(int status)
Set the HTTP status to be returned with this response.void
setStream(OutputStream stream)
Set the output stream associated with this Response.void
setSuspended(boolean suspended)
Set the suspended flag.void
setTrailerFields(Supplier<Map<String,String>> supplier)
void
setUpgrade(boolean upgrade)
protected String
toAbsolute(String location)
Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.protected String
toEncoded(String url, String sessionId)
Return the specified URL with the specified session identifier suitably encoded.
-
-
-
Field Detail
-
HTTP_RESPONSE_DATE_HEADER
public static final String HTTP_RESPONSE_DATE_HEADER
- See Also:
- Constant Field Values
-
info
protected static final String info
Descriptive information about this Response implementation.- See Also:
- Constant Field Values
-
format
protected SimpleDateFormat format
The date format we will use for creating date headers.
-
context
protected Context context
Associated context.
-
upgrade
protected boolean upgrade
-
connector
protected Connector connector
Associated Catalina connector.
-
coyoteResponse
protected org.glassfish.grizzly.http.server.Response coyoteResponse
Coyote response.
-
outputBuffer
protected OutputBuffer outputBuffer
The associated output buffer.
-
outputStream
protected CoyoteOutputStream outputStream
The associated output stream.
-
writer
protected CoyoteWriter writer
The associated writer.
-
appCommitted
protected boolean appCommitted
The application commit flag.
-
included
protected boolean included
The included flag.
-
error
protected boolean error
The error flag.
-
usingOutputStream
protected boolean usingOutputStream
Using output stream flag.
-
usingWriter
protected boolean usingWriter
Using writer flag.
-
urlEncoder
protected org.glassfish.grizzly.http.util.UEncoder urlEncoder
URL encoder.
-
redirectURLCC
protected org.glassfish.grizzly.http.util.CharChunk redirectURLCC
Recyclable buffer to hold the redirect URL.
-
request
protected Request request
The request with which this response is associated.
-
facade
protected ResponseFacade facade
The facade associated with this response.
-
-
Method Detail
-
setEnforceScope
public static void setEnforceScope(boolean enforce)
Set whether or not to enforce scope checking of this object.
-
getConnector
public Connector getConnector()
Return the Connector through which this Request was received.- Specified by:
getConnector
in interfaceResponse
- Returns:
- the Connector
-
setConnector
public void setConnector(Connector connector)
Set the Connector through which this Request was received.- Specified by:
setConnector
in interfaceResponse
- Parameters:
connector
- The new connector
-
setCoyoteResponse
public void setCoyoteResponse(org.glassfish.grizzly.http.server.Response coyoteResponse)
Set the Coyote response.- Parameters:
coyoteResponse
- The Coyote response
-
getCoyoteResponse
public org.glassfish.grizzly.http.server.Response getCoyoteResponse()
Get the Coyote response.
-
getContext
public Context getContext()
Return the Context within which this Request is being processed.- Specified by:
getContext
in interfaceResponse
- Returns:
- the Context
-
setContext
public void setContext(Context context)
Set the Context within which this Request is being processed. This must be called as soon as the appropriate Context is identified, because it identifies the value to be returned bygetContextPath()
, and thus enables parsing of the request URI.- Specified by:
setContext
in interfaceResponse
- Parameters:
context
- The newly associated Context
-
recycle
public void recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object.
-
getContentCount
public int getContentCount()
Return the number of bytes actually written to the output stream.- Specified by:
getContentCount
in interfaceResponse
- Returns:
- the number of bytes
-
setAppCommitted
public void setAppCommitted(boolean appCommitted)
Set the application commit flag.- Specified by:
setAppCommitted
in interfaceResponse
- Parameters:
appCommitted
- The new application committed flag value
-
isAppCommitted
public boolean isAppCommitted()
Application commit flag accessor.- Specified by:
isAppCommitted
in interfaceResponse
- Returns:
- If the app is committed, suspended or has no content
-
getIncluded
public boolean getIncluded()
Return the "processing inside an include" flag.- Specified by:
getIncluded
in interfaceResponse
- Returns:
- included flag
-
setIncluded
public void setIncluded(boolean included)
Set the "processing inside an include" flag.- Specified by:
setIncluded
in interfaceResponse
- Parameters:
included
-true
if we are currently inside a RequestDispatcher.include(), elsefalse
-
getInfo
public String getInfo()
Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>
.
-
getRequest
public Request getRequest()
Return the Request with which this Response is associated.- Specified by:
getRequest
in interfaceResponse
- Returns:
- the Request
-
setRequest
public void setRequest(Request request)
Set the Request with which this Response is associated.- Specified by:
setRequest
in interfaceResponse
- Parameters:
request
- The new associated request
-
getResponse
public jakarta.servlet.http.HttpServletResponse getResponse()
Return theServletResponse
for which this object is the facade.- Specified by:
getResponse
in interfaceResponse
- Returns:
- the HttpServletResponse
-
getStream
public OutputStream getStream()
Return the output stream associated with this Response.
-
setStream
public void setStream(OutputStream stream)
Set the output stream associated with this Response.
-
setSuspended
public void setSuspended(boolean suspended)
Set the suspended flag.- Specified by:
setSuspended
in interfaceResponse
- Parameters:
suspended
- The new suspended flag value
-
isSuspended
public boolean isSuspended()
Suspended flag accessor.- Specified by:
isSuspended
in interfaceResponse
- Returns:
- Suspended flag
-
setDetailMessage
public void setDetailMessage(String message)
Sets detail error message.- Specified by:
setDetailMessage
in interfaceResponse
- Parameters:
message
- detail error message
-
getDetailMessage
public String getDetailMessage()
Gets detail error message.- Specified by:
getDetailMessage
in interfaceResponse
- Returns:
- the detail error message
-
createOutputStream
public jakarta.servlet.ServletOutputStream createOutputStream() throws IOException
Create and return a ServletOutputStream to write the content associated with this Response.- Specified by:
createOutputStream
in interfaceResponse
- Throws:
IOException
- if an input/output error occurs
-
finishResponse
public void finishResponse() throws IOException
Perform whatever actions are required to flush and close the output stream or writer, in a single operation.- Specified by:
finishResponse
in interfaceResponse
- Throws:
IOException
- if an input/output error occurs
-
getContentLength
public int getContentLength()
Return the content length that was set or calculated for this Response.- Specified by:
getContentLength
in interfaceResponse
- Returns:
- the content length
-
getContentType
public String getContentType()
Return the content type that was set or calculated for this response, ornull
if no content type was set.- Specified by:
getContentType
in interfaceResponse
- Specified by:
getContentType
in interfacejakarta.servlet.ServletResponse
- Returns:
- the content type
-
getReporter
public PrintWriter getReporter() throws IOException
Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired.- Specified by:
getReporter
in interfaceResponse
- Returns:
- Writer which can be used for error reports. If the response is not an error report returned using sendError or triggered by an unexpected exception thrown during the servlet processing (and only in that case), null will be returned if the response stream has already been used.
- Throws:
IOException
- if an input/output error occurs
-
flushBuffer
public void flushBuffer() throws IOException
Flush the buffer and commit this response.- Specified by:
flushBuffer
in interfacejakarta.servlet.ServletResponse
- Throws:
IOException
- if an input/output error occurs
-
getBufferSize
public int getBufferSize()
Return the actual buffer size used for this Response.- Specified by:
getBufferSize
in interfacejakarta.servlet.ServletResponse
- Returns:
- buffer size in bytes
-
getCharacterEncoding
public String getCharacterEncoding()
Return the character encoding used for this Response.- Specified by:
getCharacterEncoding
in interfacejakarta.servlet.ServletResponse
- Returns:
- character encoding i.e. UTF-8
-
setCharacterEncoding
public void setCharacterEncoding(String charset)
Overrides the name of the character encoding used in the body of the request. This method must be called prior to reading request parameters or reading input using getReader().- Specified by:
setCharacterEncoding
in interfacejakarta.servlet.ServletResponse
- Parameters:
charset
- String containing the name of the character encoding.
-
getOutputStream
public jakarta.servlet.ServletOutputStream getOutputStream() throws IOException
Return the servlet output stream associated with this Response.- Specified by:
getOutputStream
in interfacejakarta.servlet.ServletResponse
- Returns:
- the servlet output stream
- Throws:
IllegalStateException
- ifgetWriter
has already been called for this responseIOException
- if an input/output error occurs
-
getLocale
public Locale getLocale()
Return the Locale assigned to this response.- Specified by:
getLocale
in interfacejakarta.servlet.ServletResponse
- Returns:
- assigned Locale
-
getWriter
public PrintWriter getWriter() throws IOException
Return the writer associated with this Response.- Specified by:
getWriter
in interfacejakarta.servlet.ServletResponse
- Returns:
- associated writer
- Throws:
IllegalStateException
- ifgetOutputStream
has already been called for this responseIOException
- if an input/output error occurs
-
isCommitted
public boolean isCommitted()
Has the output of this response already been committed?- Specified by:
isCommitted
in interfacejakarta.servlet.ServletResponse
- Returns:
- If the response is committed
-
reset
public void reset()
Clear any content written to the buffer.- Specified by:
reset
in interfacejakarta.servlet.ServletResponse
- Throws:
IllegalStateException
- if this response has already been committed
-
resetBuffer
public void resetBuffer()
Reset the data buffer but not any status or header information.- Specified by:
resetBuffer
in interfaceResponse
- Specified by:
resetBuffer
in interfacejakarta.servlet.ServletResponse
- Throws:
IllegalStateException
- if the response has already been committed
-
resetBuffer
public void resetBuffer(boolean resetWriterStreamFlags)
Reset the data buffer and the using Writer/Stream flags but not any status or header information.- Specified by:
resetBuffer
in interfaceResponse
- Parameters:
resetWriterStreamFlags
-true
if the internalusingWriter
,usingOutputStream
,isCharacterEncodingSet
flags should also be reset- Throws:
IllegalStateException
- if the response has already been committed
-
setBufferSize
public void setBufferSize(int size)
Set the buffer size to be used for this Response.- Specified by:
setBufferSize
in interfacejakarta.servlet.ServletResponse
- Parameters:
size
- The new buffer size- Throws:
IllegalStateException
- if this method is called after output has been committed for this response
-
setContentLength
public void setContentLength(int length)
Set the content length (in bytes) for this Response.- Specified by:
setContentLength
in interfacejakarta.servlet.ServletResponse
- Parameters:
length
- The new content length
-
setContentLengthLong
public void setContentLengthLong(long length)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.- Specified by:
setContentLengthLong
in interfacejakarta.servlet.ServletResponse
- Parameters:
length
- The new content length
-
setContentType
public void setContentType(String type)
Set the content type for this Response.- Specified by:
setContentType
in interfacejakarta.servlet.ServletResponse
- Parameters:
type
- The new content type
-
setLocale
public void setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding.- Specified by:
setLocale
in interfacejakarta.servlet.ServletResponse
- Parameters:
locale
- The new locale
-
getHeader
public String getHeader(String name)
Return the value for the specified header, ornull
if this header has not been set. If more than one value was added for this name, only the first is returned; usegetHeaders(String)
to retrieve all of them.- Specified by:
getHeader
in interfaceHttpResponse
- Specified by:
getHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Header name to look up
-
getHeaderNames
public Collection<String> getHeaderNames()
- Specified by:
getHeaderNames
in interfaceHttpResponse
- Specified by:
getHeaderNames
in interfacejakarta.servlet.http.HttpServletResponse
- Returns:
- a (possibly empty)
Collection
of the names of the headers of this response
-
getHeaders
public Collection<String> getHeaders(String name)
- Specified by:
getHeaders
in interfaceHttpResponse
- Specified by:
getHeaders
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- the name of the response header whose values to return- Returns:
- a (possibly empty)
Collection
of the values of the response header with the given name
-
getMessage
public String getMessage()
Return the error message that was set withsendError()
for this Response.- Specified by:
getMessage
in interfaceHttpResponse
- Returns:
- the error message
-
getStatus
public int getStatus()
Return the HTTP status code associated with this Response.- Specified by:
getStatus
in interfaceHttpResponse
- Specified by:
getStatus
in interfacejakarta.servlet.http.HttpServletResponse
- Returns:
- HTTP status code
-
reset
public void reset(int status, String message)
Reset this response, and specify the values for the HTTP status code and corresponding message.- Specified by:
reset
in interfaceHttpResponse
- Parameters:
status
- The new HTTP statusmessage
- The corresponding message- Throws:
IllegalStateException
- if this response has already been committed
-
addCookie
public void addCookie(jakarta.servlet.http.Cookie cookie)
Add the specified Cookie to those that will be included with this Response.- Specified by:
addCookie
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
cookie
- Cookie to be added
-
addSessionCookieInternal
public void addSessionCookieInternal(jakarta.servlet.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding any previous- Specified by:
addSessionCookieInternal
in interfaceHttpResponse
- Parameters:
cookie
-
-
addDateHeader
public void addDateHeader(String name, long value)
Add the specified date header to the specified value.- Specified by:
addDateHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to setvalue
- Date value to be set
-
addHeader
public void addHeader(String name, String value)
Add the specified header to the specified value.- Specified by:
addHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to setvalue
- Value to be set
-
addIntHeader
public void addIntHeader(String name, int value)
Add the specified integer header to the specified value.- Specified by:
addIntHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to setvalue
- Integer value to be set
-
containsHeader
public boolean containsHeader(String name)
Has the specified header been set already in this response?- Specified by:
containsHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to check- Returns:
- If header is set
-
encodeRedirectURL
public String encodeRedirectURL(String url)
Encode the session identifier associated with this response into the specified redirect URL, if necessary.- Specified by:
encodeRedirectURL
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
url
- URL to be encoded- Returns:
- encoded URL
-
getTrailerFields
public Supplier<Map<String,String>> getTrailerFields()
- Specified by:
getTrailerFields
in interfacejakarta.servlet.http.HttpServletResponse
-
setTrailerFields
public void setTrailerFields(Supplier<Map<String,String>> supplier)
- Specified by:
setTrailerFields
in interfacejakarta.servlet.http.HttpServletResponse
-
encodeURL
public String encodeURL(String url)
Encode the session identifier associated with this response into the specified URL, if necessary.- Specified by:
encodeURL
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
url
- URL to be encoded- Returns:
-
encode
public String encode(String url)
Apply URL Encoding to the given URL without adding session identifier et al associated to this response.
-
sendAcknowledgement
public void sendAcknowledgement() throws IOException
Send an acknowledgment of a request.- Specified by:
sendAcknowledgement
in interfaceHttpResponse
- Specified by:
sendAcknowledgement
in interfaceResponse
- Throws:
IOException
- if an input/output error occurs
-
sendError
public void sendError(int status) throws IOException
Send an error response with the specified status and a default message.- Specified by:
sendError
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
status
- HTTP status code to send- Throws:
IllegalStateException
- if this response has already been committedIOException
- if an input/output error occurs
-
sendError
public void sendError(int status, String message) throws IOException
Send an error response with the specified status and message.- Specified by:
sendError
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
status
- HTTP status code to sendmessage
- Corresponding message to send- Throws:
IllegalStateException
- if this response has already been committedIOException
- if an input/output error occurs
-
sendRedirect
public void sendRedirect(String location) throws IOException
Sends a temporary redirect to the specified redirect location URL.- Specified by:
sendRedirect
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
location
- Location URL to redirect to- Throws:
IllegalStateException
- if this response has already been committedIOException
- if an input/output error occurs
-
sendRedirect
public void sendRedirect(String location, boolean isTemporary) throws IOException
Sends a temporary or permanent redirect to the specified redirect location URL.- Parameters:
location
- Location URL to redirect toisTemporary
- true if the redirect is supposed to be temporary, false if permanent- Throws:
IllegalStateException
- if this response has already been committedIOException
- if an input/output error occurs
-
setDateHeader
public void setDateHeader(String name, long value)
Set the specified date header to the specified value.- Specified by:
setDateHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to setvalue
- Date value to be set
-
setHeader
public void setHeader(String name, String value)
Set the specified header to the specified value.- Specified by:
setHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to setvalue
- Value to be set
-
setIntHeader
public void setIntHeader(String name, int value)
Set the specified integer header to the specified value.- Specified by:
setIntHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
name
- Name of the header to setvalue
- Integer value to be set
-
setStatus
public void setStatus(int status)
Set the HTTP status to be returned with this response.- Specified by:
setStatus
in interfacejakarta.servlet.http.HttpServletResponse
- Parameters:
status
- The new HTTP status
-
isEncodeable
protected boolean isEncodeable(String location)
Returntrue
if the specified URL should be encoded with a session identifier. This will be true if all of the following conditions are met:- The request we are responding to asked for a valid session
- The requested session ID was not received via a cookie
- The specified URL points back to somewhere within the web application that is responding to this request
- Parameters:
location
- Absolute URL to be validated
-
toAbsolute
protected String toAbsolute(String location)
Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL. If this URL is already absolute, return it unchanged.- Parameters:
location
- URL to be (possibly) converted and then returned- Throws:
IllegalArgumentException
- if a MalformedURLException is thrown when converting the relative URL to an absolute one
-
toEncoded
protected String toEncoded(String url, String sessionId)
Return the specified URL with the specified session identifier suitably encoded.- Parameters:
url
- URL to be encoded with the session idsessionId
- Session id to be included in the encoded URL
-
createWriter
protected CoyoteWriter createWriter(OutputBuffer outbuf)
Create an instance of CoyoteWriter
-
getCookieString
protected String getCookieString(jakarta.servlet.http.Cookie cookie)
Gets the string representation of the given cookie.- Parameters:
cookie
- The cookie whose string representation to get- Returns:
- The cookie's string representation
-
removeSessionCookies
public void removeSessionCookies()
Removes any Set-Cookie response headers whose value contains the string JSESSIONID
-
setUpgrade
public void setUpgrade(boolean upgrade)
-
-