Package com.sun.web.security
Class HttpResponseWrapper
- java.lang.Object
-
- jakarta.servlet.ServletResponseWrapper
-
- jakarta.servlet.http.HttpServletResponseWrapper
-
- com.sun.web.security.HttpResponseWrapper
-
- All Implemented Interfaces:
jakarta.servlet.http.HttpServletResponse
,jakarta.servlet.ServletResponse
,HttpResponse
,Response
public class HttpResponseWrapper extends jakarta.servlet.http.HttpServletResponseWrapper implements HttpResponse
-
-
Field Summary
-
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
-
-
Constructor Summary
Constructors Constructor Description HttpResponseWrapper(HttpResponse response, jakarta.servlet.http.HttpServletResponse servletResponse)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addSessionCookieInternal(jakarta.servlet.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding any previousjakarta.servlet.ServletOutputStream
createOutputStream()
Create and return a ServletOutputStream to write the content associated with this Response.String
encode(String url)
Apply URL Encoding to the given URL without adding session identifier et al associated to this response.void
finishResponse()
Perform whatever actions are required to flush and close the output stream or writer, in a single operation.Connector
getConnector()
Return the Connector through which this Response is returned.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.Context
getContext()
Return the Context with which this Response is associated.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>
.String
getMessage()
Return the error message that was set withsendError()
for 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.ServletResponse
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.boolean
isAppCommitted()
Application commit flag accessor.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
reset(int status, String message)
Reset this response, and specify the values for the HTTP status code and corresponding message.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
setAppCommitted(boolean appCommitted)
Set the application commit flag.void
setConnector(Connector connector)
Set the Connector through which this Response is returned.void
setContext(Context context)
Set the Context with which this Response is associated.void
setDetailMessage(String message)
Sets detail error message.void
setError()
Set the error flag.void
setIncluded(boolean included)
Set the "processing inside an include" flag.void
setRequest(Request request)
Set the Request with which this Response is associated.void
setStream(OutputStream stream)
Set the output stream associated with this Response.void
setSuspended(boolean suspended)
Set the suspended flag.-
Methods inherited from class jakarta.servlet.http.HttpServletResponseWrapper
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectURL, encodeURL, getTrailerFields, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setTrailerFields
-
Methods inherited from class jakarta.servlet.ServletResponseWrapper
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, isWrapperFor, isWrapperFor, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale, setResponse
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.catalina.Response
getContentType, resetBuffer
-
Methods inherited from interface jakarta.servlet.ServletResponse
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale
-
-
-
-
Constructor Detail
-
HttpResponseWrapper
public HttpResponseWrapper(HttpResponse response, jakarta.servlet.http.HttpServletResponse servletResponse)
-
-
Method Detail
-
getHeader
public String getHeader(String name)
Description copied from interface:HttpResponse
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; useHttpResponse.getHeaders(String)
to retrieve all of them.- Specified by:
getHeader
in interfaceHttpResponse
- Specified by:
getHeader
in interfacejakarta.servlet.http.HttpServletResponse
- Overrides:
getHeader
in classjakarta.servlet.http.HttpServletResponseWrapper
- 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
- Overrides:
getHeaderNames
in classjakarta.servlet.http.HttpServletResponseWrapper
- 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
- Overrides:
getHeaders
in classjakarta.servlet.http.HttpServletResponseWrapper
- 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
-
addSessionCookieInternal
public void addSessionCookieInternal(jakarta.servlet.http.Cookie cookie)
Description copied from interface:HttpResponse
Special method for adding a session cookie as we should be overriding any previous- Specified by:
addSessionCookieInternal
in interfaceHttpResponse
-
getMessage
public String getMessage()
Description copied from interface:HttpResponse
Return the error message that was set withsendError()
for this Response.- Specified by:
getMessage
in interfaceHttpResponse
-
getStatus
public int getStatus()
Description copied from interface:HttpResponse
Return the HTTP status code associated with this Response.- Specified by:
getStatus
in interfaceHttpResponse
- Specified by:
getStatus
in interfacejakarta.servlet.http.HttpServletResponse
- Overrides:
getStatus
in classjakarta.servlet.http.HttpServletResponseWrapper
-
reset
public void reset(int status, String message)
Description copied from interface:HttpResponse
Reset this response, and specify the values for the HTTP status code and corresponding message.- Specified by:
reset
in interfaceHttpResponse
-
getConnector
public Connector getConnector()
Description copied from interface:Response
Return the Connector through which this Response is returned.- Specified by:
getConnector
in interfaceResponse
-
setConnector
public void setConnector(Connector connector)
Description copied from interface:Response
Set the Connector through which this Response is returned.- Specified by:
setConnector
in interfaceResponse
- Parameters:
connector
- The new connector
-
getContentCount
public int getContentCount()
Description copied from interface:Response
Return the number of bytes actually written to the output stream.- Specified by:
getContentCount
in interfaceResponse
-
getContext
public Context getContext()
Description copied from interface:Response
Return the Context with which this Response is associated.- Specified by:
getContext
in interfaceResponse
-
setContext
public void setContext(Context context)
Description copied from interface:Response
Set the Context with which this Response is associated. This should be called as soon as the appropriate Context is identified.- Specified by:
setContext
in interfaceResponse
- Parameters:
context
- The associated Context
-
setAppCommitted
public void setAppCommitted(boolean appCommitted)
Description copied from interface:Response
Set the application commit flag.- Specified by:
setAppCommitted
in interfaceResponse
- Parameters:
appCommitted
- The new application committed flag value
-
isAppCommitted
public boolean isAppCommitted()
Description copied from interface:Response
Application commit flag accessor.- Specified by:
isAppCommitted
in interfaceResponse
-
getIncluded
public boolean getIncluded()
Description copied from interface:Response
Return the "processing inside an include" flag.- Specified by:
getIncluded
in interfaceResponse
-
setIncluded
public void setIncluded(boolean included)
Description copied from interface:Response
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()
Description copied from interface:Response
Return descriptive information about this Response implementation and the corresponding version number, in the format<description>/<version>
.
-
getRequest
public Request getRequest()
Description copied from interface:Response
Return the Request with which this Response is associated.- Specified by:
getRequest
in interfaceResponse
-
setRequest
public void setRequest(Request request)
Description copied from interface:Response
Set the Request with which this Response is associated.- Specified by:
setRequest
in interfaceResponse
- Parameters:
request
- The new associated request
-
getResponse
public jakarta.servlet.ServletResponse getResponse()
Description copied from interface:Response
Return theServletResponse
for which this object is the facade.- Specified by:
getResponse
in interfaceResponse
- Overrides:
getResponse
in classjakarta.servlet.ServletResponseWrapper
-
getStream
public OutputStream getStream()
Description copied from interface:Response
Return the output stream associated with this Response.
-
setStream
public void setStream(OutputStream stream)
Description copied from interface:Response
Set the output stream associated with this Response.
-
setSuspended
public void setSuspended(boolean suspended)
Description copied from interface:Response
Set the suspended flag.- Specified by:
setSuspended
in interfaceResponse
- Parameters:
suspended
- The new suspended flag value
-
isSuspended
public boolean isSuspended()
Description copied from interface:Response
Suspended flag accessor.- Specified by:
isSuspended
in interfaceResponse
-
setError
public void setError()
Description copied from interface:Response
Set the error flag.
-
isError
public boolean isError()
Description copied from interface:Response
Error flag accessor.
-
setDetailMessage
public void setDetailMessage(String message)
Description copied from interface:Response
Sets detail error message.- Specified by:
setDetailMessage
in interfaceResponse
- Parameters:
message
- detail error message
-
getDetailMessage
public String getDetailMessage()
Description copied from interface:Response
Gets detail error message.- Specified by:
getDetailMessage
in interfaceResponse
- Returns:
- the detail error message
-
createOutputStream
public jakarta.servlet.ServletOutputStream createOutputStream() throws IOException
Description copied from interface:Response
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
Description copied from interface:Response
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()
Description copied from interface:Response
Return the content length that was set or calculated for this Response.- Specified by:
getContentLength
in interfaceResponse
-
getReporter
public PrintWriter getReporter() throws IOException
Description copied from interface:Response
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
-
recycle
public void recycle()
Description copied from interface:Response
Release all object references, and initialize instance variables, in preparation for reuse of this object.
-
resetBuffer
public void resetBuffer(boolean resetWriterStreamFlags)
Description copied from interface:Response
Reset the data buffer and the using Writer/Stream flags but not any status or header information.- Specified by:
resetBuffer
in interfaceResponse
-
sendAcknowledgement
public void sendAcknowledgement() throws IOException
Description copied from interface:HttpResponse
Send an acknowledgment of a request. An acknowledgment in this case is simply an HTTP response status line, i.e.HTTP/1.1 [STATUS] [REASON-PHRASE]
.
- Specified by:
sendAcknowledgement
in interfaceHttpResponse
- Specified by:
sendAcknowledgement
in interfaceResponse
- Throws:
IOException
- if an input/output error occurs
-
-