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 booleanappCommittedThe application commit flag.protected ConnectorconnectorAssociated Catalina connector.protected ContextcontextAssociated context.protected org.glassfish.grizzly.http.server.ResponsecoyoteResponseCoyote response.protected booleanerrorThe error flag.protected ResponseFacadefacadeThe facade associated with this response.protected SimpleDateFormatformatThe date format we will use for creating date headers.static StringHTTP_RESPONSE_DATE_HEADERprotected booleanincludedThe included flag.protected static StringinfoDescriptive information about this Response implementation.protected OutputBufferoutputBufferThe associated output buffer.protected CoyoteOutputStreamoutputStreamThe associated output stream.protected org.glassfish.grizzly.http.util.CharChunkredirectURLCCRecyclable buffer to hold the redirect URL.protected RequestrequestThe request with which this response is associated.protected booleanupgradeprotected org.glassfish.grizzly.http.util.UEncoderurlEncoderURL encoder.protected booleanusingOutputStreamUsing output stream flag.protected booleanusingWriterUsing writer flag.protected CoyoteWriterwriterThe 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 voidaddCookie(jakarta.servlet.http.Cookie cookie)Add the specified Cookie to those that will be included with this Response.voidaddDateHeader(String name, long value)Add the specified date header to the specified value.voidaddHeader(String name, String value)Add the specified header to the specified value.voidaddIntHeader(String name, int value)Add the specified integer header to the specified value.voidaddSessionCookieInternal(jakarta.servlet.http.Cookie cookie)Special method for adding a session cookie as we should be overriding any previousbooleancontainsHeader(String name)Has the specified header been set already in this response?jakarta.servlet.ServletOutputStreamcreateOutputStream()Create and return a ServletOutputStream to write the content associated with this Response.protected CoyoteWritercreateWriter(OutputBuffer outbuf)Create an instance of CoyoteWriterStringencode(String url)Apply URL Encoding to the given URL without adding session identifier et al associated to this response.StringencodeRedirectURL(String url)Encode the session identifier associated with this response into the specified redirect URL, if necessary.StringencodeURL(String url)Encode the session identifier associated with this response into the specified URL, if necessary.voidfinishResponse()Perform whatever actions are required to flush and close the output stream or writer, in a single operation.voidflushBuffer()Flush the buffer and commit this response.intgetBufferSize()Return the actual buffer size used for this Response.StringgetCharacterEncoding()Return the character encoding used for this Response.ConnectorgetConnector()Return the Connector through which this Request was received.intgetContentCount()Return the number of bytes actually written to the output stream.intgetContentLength()Return the content length that was set or calculated for this Response.StringgetContentType()Return the content type that was set or calculated for this response, ornullif no content type was set.ContextgetContext()Return the Context within which this Request is being processed.protected StringgetCookieString(jakarta.servlet.http.Cookie cookie)Gets the string representation of the given cookie.org.glassfish.grizzly.http.server.ResponsegetCoyoteResponse()Get the Coyote response.StringgetDetailMessage()Gets detail error message.StringgetHeader(String name)Return the value for the specified header, ornullif this header has not been set.Collection<String>getHeaderNames()Collection<String>getHeaders(String name)booleangetIncluded()Return the "processing inside an include" flag.StringgetInfo()Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>.LocalegetLocale()Return the Locale assigned to this response.StringgetMessage()Return the error message that was set withsendError()for this Response.jakarta.servlet.ServletOutputStreamgetOutputStream()Return the servlet output stream associated with this Response.PrintWritergetReporter()Return a PrintWriter that can be used to render error messages, regardless of whether a stream or writer has already been acquired.RequestgetRequest()Return the Request with which this Response is associated.jakarta.servlet.http.HttpServletResponsegetResponse()Return theServletResponsefor which this object is the facade.intgetStatus()Return the HTTP status code associated with this Response.OutputStreamgetStream()Return the output stream associated with this Response.Supplier<Map<String,String>>getTrailerFields()PrintWritergetWriter()Return the writer associated with this Response.booleanisAppCommitted()Application commit flag accessor.booleanisCommitted()Has the output of this response already been committed?protected booleanisEncodeable(String location)Returntrueif the specified URL should be encoded with a session identifier.booleanisError()Error flag accessor.booleanisSuspended()Suspended flag accessor.voidrecycle()Release all object references, and initialize instance variables, in preparation for reuse of this object.voidremoveSessionCookies()Removes any Set-Cookie response headers whose value contains the string JSESSIONIDvoidreset()Clear any content written to the buffer.voidreset(int status, String message)Reset this response, and specify the values for the HTTP status code and corresponding message.voidresetBuffer()Reset the data buffer but not any status or header information.voidresetBuffer(boolean resetWriterStreamFlags)Reset the data buffer and the using Writer/Stream flags but not any status or header information.voidsendAcknowledgement()Send an acknowledgment of a request.voidsendError(int status)Send an error response with the specified status and a default message.voidsendError(int status, String message)Send an error response with the specified status and message.voidsendRedirect(String location)Sends a temporary redirect to the specified redirect location URL.voidsendRedirect(String location, boolean isTemporary)Sends a temporary or permanent redirect to the specified redirect location URL.voidsetAppCommitted(boolean appCommitted)Set the application commit flag.voidsetBufferSize(int size)Set the buffer size to be used for this Response.voidsetCharacterEncoding(String charset)Overrides the name of the character encoding used in the body of the request.voidsetConnector(Connector connector)Set the Connector through which this Request was received.voidsetContentLength(int length)Set the content length (in bytes) for this Response.voidsetContentLengthLong(long length)Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.voidsetContentType(String type)Set the content type for this Response.voidsetContext(Context context)Set the Context within which this Request is being processed.voidsetCoyoteResponse(org.glassfish.grizzly.http.server.Response coyoteResponse)Set the Coyote response.voidsetDateHeader(String name, long value)Set the specified date header to the specified value.voidsetDetailMessage(String message)Sets detail error message.static voidsetEnforceScope(boolean enforce)Set whether or not to enforce scope checking of this object.voidsetError()Set the error flag.voidsetHeader(String name, String value)Set the specified header to the specified value.voidsetIncluded(boolean included)Set the "processing inside an include" flag.voidsetIntHeader(String name, int value)Set the specified integer header to the specified value.voidsetLocale(Locale locale)Set the Locale that is appropriate for this response, including setting the appropriate character encoding.voidsetRequest(Request request)Set the Request with which this Response is associated.voidsetStatus(int status)Set the HTTP status to be returned with this response.voidsetStream(OutputStream stream)Set the output stream associated with this Response.voidsetSuspended(boolean suspended)Set the suspended flag.voidsetTrailerFields(Supplier<Map<String,String>> supplier)voidsetUpgrade(boolean upgrade)protected StringtoAbsolute(String location)Convert (if necessary) and return the absolute URL that represents the resource referenced by this possibly relative URL.protected StringtoEncoded(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:
getConnectorin interfaceResponse- Returns:
- the Connector
-
setConnector
public void setConnector(Connector connector)
Set the Connector through which this Request was received.- Specified by:
setConnectorin 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:
getContextin 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:
setContextin 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:
getContentCountin interfaceResponse- Returns:
- the number of bytes
-
setAppCommitted
public void setAppCommitted(boolean appCommitted)
Set the application commit flag.- Specified by:
setAppCommittedin interfaceResponse- Parameters:
appCommitted- The new application committed flag value
-
isAppCommitted
public boolean isAppCommitted()
Application commit flag accessor.- Specified by:
isAppCommittedin 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:
getIncludedin interfaceResponse- Returns:
- included flag
-
setIncluded
public void setIncluded(boolean included)
Set the "processing inside an include" flag.- Specified by:
setIncludedin interfaceResponse- Parameters:
included-trueif 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:
getRequestin interfaceResponse- Returns:
- the Request
-
setRequest
public void setRequest(Request request)
Set the Request with which this Response is associated.- Specified by:
setRequestin interfaceResponse- Parameters:
request- The new associated request
-
getResponse
public jakarta.servlet.http.HttpServletResponse getResponse()
Return theServletResponsefor which this object is the facade.- Specified by:
getResponsein 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:
setSuspendedin interfaceResponse- Parameters:
suspended- The new suspended flag value
-
isSuspended
public boolean isSuspended()
Suspended flag accessor.- Specified by:
isSuspendedin interfaceResponse- Returns:
- Suspended flag
-
setDetailMessage
public void setDetailMessage(String message)
Sets detail error message.- Specified by:
setDetailMessagein interfaceResponse- Parameters:
message- detail error message
-
getDetailMessage
public String getDetailMessage()
Gets detail error message.- Specified by:
getDetailMessagein interfaceResponse- Returns:
- the detail error message
-
createOutputStream
public jakarta.servlet.ServletOutputStream createOutputStream() throws IOExceptionCreate and return a ServletOutputStream to write the content associated with this Response.- Specified by:
createOutputStreamin interfaceResponse- Throws:
IOException- if an input/output error occurs
-
finishResponse
public void finishResponse() throws IOExceptionPerform whatever actions are required to flush and close the output stream or writer, in a single operation.- Specified by:
finishResponsein 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:
getContentLengthin interfaceResponse- Returns:
- the content length
-
getContentType
public String getContentType()
Return the content type that was set or calculated for this response, ornullif no content type was set.- Specified by:
getContentTypein interfaceResponse- Specified by:
getContentTypein 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:
getReporterin 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 IOExceptionFlush the buffer and commit this response.- Specified by:
flushBufferin 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:
getBufferSizein interfacejakarta.servlet.ServletResponse- Returns:
- buffer size in bytes
-
getCharacterEncoding
public String getCharacterEncoding()
Return the character encoding used for this Response.- Specified by:
getCharacterEncodingin 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:
setCharacterEncodingin interfacejakarta.servlet.ServletResponse- Parameters:
charset- String containing the name of the character encoding.
-
getOutputStream
public jakarta.servlet.ServletOutputStream getOutputStream() throws IOExceptionReturn the servlet output stream associated with this Response.- Specified by:
getOutputStreamin interfacejakarta.servlet.ServletResponse- Returns:
- the servlet output stream
- Throws:
IllegalStateException- ifgetWriterhas 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:
getLocalein interfacejakarta.servlet.ServletResponse- Returns:
- assigned Locale
-
getWriter
public PrintWriter getWriter() throws IOException
Return the writer associated with this Response.- Specified by:
getWriterin interfacejakarta.servlet.ServletResponse- Returns:
- associated writer
- Throws:
IllegalStateException- ifgetOutputStreamhas 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:
isCommittedin interfacejakarta.servlet.ServletResponse- Returns:
- If the response is committed
-
reset
public void reset()
Clear any content written to the buffer.- Specified by:
resetin 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:
resetBufferin interfaceResponse- Specified by:
resetBufferin 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:
resetBufferin interfaceResponse- Parameters:
resetWriterStreamFlags-trueif the internalusingWriter,usingOutputStream,isCharacterEncodingSetflags 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:
setBufferSizein 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:
setContentLengthin 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:
setContentLengthLongin interfacejakarta.servlet.ServletResponse- Parameters:
length- The new content length
-
setContentType
public void setContentType(String type)
Set the content type for this Response.- Specified by:
setContentTypein 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:
setLocalein interfacejakarta.servlet.ServletResponse- Parameters:
locale- The new locale
-
getHeader
public String getHeader(String name)
Return the value for the specified header, ornullif 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:
getHeaderin interfaceHttpResponse- Specified by:
getHeaderin interfacejakarta.servlet.http.HttpServletResponse- Parameters:
name- Header name to look up
-
getHeaderNames
public Collection<String> getHeaderNames()
- Specified by:
getHeaderNamesin interfaceHttpResponse- Specified by:
getHeaderNamesin interfacejakarta.servlet.http.HttpServletResponse- Returns:
- a (possibly empty)
Collectionof the names of the headers of this response
-
getHeaders
public Collection<String> getHeaders(String name)
- Specified by:
getHeadersin interfaceHttpResponse- Specified by:
getHeadersin interfacejakarta.servlet.http.HttpServletResponse- Parameters:
name- the name of the response header whose values to return- Returns:
- a (possibly empty)
Collectionof 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:
getMessagein interfaceHttpResponse- Returns:
- the error message
-
getStatus
public int getStatus()
Return the HTTP status code associated with this Response.- Specified by:
getStatusin interfaceHttpResponse- Specified by:
getStatusin 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:
resetin 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:
addCookiein 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:
addSessionCookieInternalin interfaceHttpResponse- Parameters:
cookie-
-
addDateHeader
public void addDateHeader(String name, long value)
Add the specified date header to the specified value.- Specified by:
addDateHeaderin 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:
addHeaderin 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:
addIntHeaderin 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:
containsHeaderin 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:
encodeRedirectURLin interfacejakarta.servlet.http.HttpServletResponse- Parameters:
url- URL to be encoded- Returns:
- encoded URL
-
getTrailerFields
public Supplier<Map<String,String>> getTrailerFields()
- Specified by:
getTrailerFieldsin interfacejakarta.servlet.http.HttpServletResponse
-
setTrailerFields
public void setTrailerFields(Supplier<Map<String,String>> supplier)
- Specified by:
setTrailerFieldsin 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:
encodeURLin 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 IOExceptionSend an acknowledgment of a request.- Specified by:
sendAcknowledgementin interfaceHttpResponse- Specified by:
sendAcknowledgementin interfaceResponse- Throws:
IOException- if an input/output error occurs
-
sendError
public void sendError(int status) throws IOExceptionSend an error response with the specified status and a default message.- Specified by:
sendErrorin 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 IOExceptionSend an error response with the specified status and message.- Specified by:
sendErrorin 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:
sendRedirectin 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:
setDateHeaderin 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:
setHeaderin 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:
setIntHeaderin 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:
setStatusin interfacejakarta.servlet.http.HttpServletResponse- Parameters:
status- The new HTTP status
-
isEncodeable
protected boolean isEncodeable(String location)
Returntrueif 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)
-
-