public class HttpResponseWrapper extends javax.servlet.http.HttpServletResponseWrapper implements HttpResponse
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 and Description |
---|
HttpResponseWrapper(HttpResponse response,
javax.servlet.http.HttpServletResponse servletResponse) |
Modifier and Type | Method and Description |
---|---|
void |
addSessionCookieInternal(javax.servlet.http.Cookie cookie)
Special method for adding a session cookie as we should be overriding
any previous
|
javax.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, or
null 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 with
sendError()
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.
|
javax.servlet.ServletResponse |
getResponse()
Return the
ServletResponse 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.
|
addCookie, addDateHeader, addHeader, addIntHeader, containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getTrailerFields, sendError, sendError, sendRedirect, setDateHeader, setHeader, setIntHeader, setStatus, setStatus, setTrailerFields
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, isWrapperFor, isWrapperFor, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale, setResponse
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getContentType, resetBuffer
flushBuffer, getBufferSize, getCharacterEncoding, getContentType, getLocale, getOutputStream, getWriter, isCommitted, reset, resetBuffer, setBufferSize, setCharacterEncoding, setContentLength, setContentLengthLong, setContentType, setLocale
public HttpResponseWrapper(HttpResponse response, javax.servlet.http.HttpServletResponse servletResponse)
public String getHeader(String name)
HttpResponse
null
if this
header has not been set. If more than one value was added for this
name, only the first is returned; use HttpResponse.getHeaders(String)
to
retrieve all of them.getHeader
in interface javax.servlet.http.HttpServletResponse
getHeader
in interface HttpResponse
getHeader
in class javax.servlet.http.HttpServletResponseWrapper
name
- Header name to look uppublic Collection<String> getHeaderNames()
getHeaderNames
in interface javax.servlet.http.HttpServletResponse
getHeaderNames
in interface HttpResponse
getHeaderNames
in class javax.servlet.http.HttpServletResponseWrapper
Collection
of the names
of the headers of this responsepublic Collection<String> getHeaders(String name)
getHeaders
in interface javax.servlet.http.HttpServletResponse
getHeaders
in interface HttpResponse
getHeaders
in class javax.servlet.http.HttpServletResponseWrapper
name
- the name of the response header whose values to returnCollection
of the values
of the response header with the given namepublic void addSessionCookieInternal(javax.servlet.http.Cookie cookie)
HttpResponse
addSessionCookieInternal
in interface HttpResponse
public String getMessage()
HttpResponse
sendError()
for this Response.getMessage
in interface HttpResponse
public int getStatus()
HttpResponse
getStatus
in interface javax.servlet.http.HttpServletResponse
getStatus
in interface HttpResponse
getStatus
in class javax.servlet.http.HttpServletResponseWrapper
public void reset(int status, String message)
HttpResponse
reset
in interface HttpResponse
public Connector getConnector()
Response
getConnector
in interface Response
public void setConnector(Connector connector)
Response
setConnector
in interface Response
connector
- The new connectorpublic int getContentCount()
Response
getContentCount
in interface Response
public Context getContext()
Response
getContext
in interface Response
public void setContext(Context context)
Response
setContext
in interface Response
context
- The associated Contextpublic void setAppCommitted(boolean appCommitted)
Response
setAppCommitted
in interface Response
appCommitted
- The new application committed flag valuepublic boolean isAppCommitted()
Response
isAppCommitted
in interface Response
public boolean getIncluded()
Response
getIncluded
in interface Response
public void setIncluded(boolean included)
Response
setIncluded
in interface Response
included
- true
if we are currently inside a
RequestDispatcher.include(), else false
public String getInfo()
Response
<description>/<version>
.public Request getRequest()
Response
getRequest
in interface Response
public void setRequest(Request request)
Response
setRequest
in interface Response
request
- The new associated requestpublic javax.servlet.ServletResponse getResponse()
Response
ServletResponse
for which this object
is the facade.getResponse
in interface Response
getResponse
in class javax.servlet.ServletResponseWrapper
public OutputStream getStream()
Response
public void setStream(OutputStream stream)
Response
public void setSuspended(boolean suspended)
Response
setSuspended
in interface Response
suspended
- The new suspended flag valuepublic boolean isSuspended()
Response
isSuspended
in interface Response
public void setError()
Response
public boolean isError()
Response
public void setDetailMessage(String message)
Response
setDetailMessage
in interface Response
message
- detail error messagepublic String getDetailMessage()
Response
getDetailMessage
in interface Response
public javax.servlet.ServletOutputStream createOutputStream() throws IOException
Response
createOutputStream
in interface Response
IOException
- if an input/output error occurspublic void finishResponse() throws IOException
Response
finishResponse
in interface Response
IOException
- if an input/output error occurspublic int getContentLength()
Response
getContentLength
in interface Response
public PrintWriter getReporter() throws IOException
Response
getReporter
in interface Response
IOException
- if an input/output error occurspublic void recycle()
Response
public void resetBuffer(boolean resetWriterStreamFlags)
Response
resetBuffer
in interface Response
public void sendAcknowledgement() throws IOException
HttpResponse
HTTP/1.1 [STATUS] [REASON-PHRASE].
sendAcknowledgement
in interface HttpResponse
sendAcknowledgement
in interface Response
IOException
- if an input/output error occursCopyright © 2019. All rights reserved.