public class GenericResponseWrapper
extends javax.servlet.http.HttpServletResponseWrapper
implements java.io.Serializable
HttpServletResponseWrapper
.
It is used to wrap the real Response so that we can modify it after that the
target of the request has delivered its response.
It uses the Wrapper pattern.
Based on net.sf.ehcache.constructs.web.GenericResponseWrapper.Modifier and Type | Field and Description |
---|---|
protected int |
contentLength |
protected java.lang.String |
contentType |
protected java.util.List<javax.servlet.http.Cookie> |
cookies |
protected boolean |
disableFlushBuffer |
protected java.util.Map<java.lang.String,java.util.List<java.io.Serializable>> |
headersMap |
static org.apache.commons.logging.Log |
LOG |
protected javax.servlet.ServletOutputStream |
out |
protected int |
statusCode |
protected java.io.PrintWriter |
writer |
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 |
---|
GenericResponseWrapper(javax.servlet.http.HttpServletResponse response,
SerializableOutputStream outputStream)
Creates a GenericResponseWrapper
|
Modifier and Type | Method and Description |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie) |
void |
addDateHeader(java.lang.String name,
long date) |
void |
addHeader(java.lang.String name,
java.lang.String value) |
void |
addIntHeader(java.lang.String name,
int value) |
void |
flush()
Flushes all the streams for this response.
|
void |
flushBuffer() |
java.util.Collection<Header<? extends java.io.Serializable>> |
getAllHeaders() |
int |
getContentLength() |
java.lang.String |
getContentType() |
java.util.Collection<javax.servlet.http.Cookie> |
getCookies() |
javax.servlet.ServletOutputStream |
getOutputStream() |
int |
getStatus() |
java.io.PrintWriter |
getWriter() |
boolean |
isDisableFlushBuffer()
Is the wrapped reponse's buffer flushing disabled?
|
void |
reset() |
void |
sendError(int code)
Send the error.
|
void |
sendError(int code,
java.lang.String string)
Send the error.
|
void |
sendRedirect(java.lang.String string)
Send the redirect.
|
void |
setContentLength(int length) |
void |
setContentType(java.lang.String type) |
void |
setDateHeader(java.lang.String name,
long date) |
void |
setDisableFlushBuffer(boolean disable)
Set if the wrapped reponse's buffer flushing should be disabled.
|
void |
setHeader(java.lang.String name,
java.lang.String value) |
void |
setIntHeader(java.lang.String name,
int value) |
void |
setStatus(int code) |
void |
setStatus(int code,
java.lang.String msg) |
containsHeader, encodeRedirectUrl, encodeRedirectURL, encodeUrl, encodeURL, getHeader, getHeaderNames, getHeaders
getBufferSize, getCharacterEncoding, getLocale, getResponse, isCommitted, isWrapperFor, isWrapperFor, resetBuffer, setBufferSize, setCharacterEncoding, setContentLengthLong, setLocale, setResponse
public static final org.apache.commons.logging.Log LOG
protected int statusCode
protected int contentLength
protected java.lang.String contentType
protected final java.util.Map<java.lang.String,java.util.List<java.io.Serializable>> headersMap
protected final java.util.List<javax.servlet.http.Cookie> cookies
protected javax.servlet.ServletOutputStream out
protected transient java.io.PrintWriter writer
protected boolean disableFlushBuffer
public GenericResponseWrapper(javax.servlet.http.HttpServletResponse response, SerializableOutputStream outputStream)
public javax.servlet.ServletOutputStream getOutputStream()
getOutputStream
in interface javax.servlet.ServletResponse
getOutputStream
in class javax.servlet.ServletResponseWrapper
public void setStatus(int code)
setStatus
in interface javax.servlet.http.HttpServletResponse
setStatus
in class javax.servlet.http.HttpServletResponseWrapper
public void sendError(int code, java.lang.String string) throws java.io.IOException
sendError
in interface javax.servlet.http.HttpServletResponse
sendError
in class javax.servlet.http.HttpServletResponseWrapper
code
- the status codestring
- the error messagejava.io.IOException
public void sendError(int code) throws java.io.IOException
sendError
in interface javax.servlet.http.HttpServletResponse
sendError
in class javax.servlet.http.HttpServletResponseWrapper
code
- the status codejava.io.IOException
public void sendRedirect(java.lang.String string) throws java.io.IOException
sendRedirect
in interface javax.servlet.http.HttpServletResponse
sendRedirect
in class javax.servlet.http.HttpServletResponseWrapper
string
- the URL to redirect tojava.io.IOException
public void setStatus(int code, java.lang.String msg)
setStatus
in interface javax.servlet.http.HttpServletResponse
setStatus
in class javax.servlet.http.HttpServletResponseWrapper
public int getStatus()
getStatus
in interface javax.servlet.http.HttpServletResponse
getStatus
in class javax.servlet.http.HttpServletResponseWrapper
public void setContentLength(int length)
setContentLength
in interface javax.servlet.ServletResponse
setContentLength
in class javax.servlet.ServletResponseWrapper
public int getContentLength()
public void setContentType(java.lang.String type)
setContentType
in interface javax.servlet.ServletResponse
setContentType
in class javax.servlet.ServletResponseWrapper
public java.lang.String getContentType()
getContentType
in interface javax.servlet.ServletResponse
getContentType
in class javax.servlet.ServletResponseWrapper
public java.io.PrintWriter getWriter() throws java.io.IOException
getWriter
in interface javax.servlet.ServletResponse
getWriter
in class javax.servlet.ServletResponseWrapper
java.io.IOException
public void addHeader(java.lang.String name, java.lang.String value)
addHeader
in interface javax.servlet.http.HttpServletResponse
addHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setHeader(java.lang.String name, java.lang.String value)
setHeader
in interface javax.servlet.http.HttpServletResponse
setHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addDateHeader(java.lang.String name, long date)
addDateHeader
in interface javax.servlet.http.HttpServletResponse
addDateHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setDateHeader(java.lang.String name, long date)
setDateHeader
in interface javax.servlet.http.HttpServletResponse
setDateHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void addIntHeader(java.lang.String name, int value)
addIntHeader
in interface javax.servlet.http.HttpServletResponse
addIntHeader
in class javax.servlet.http.HttpServletResponseWrapper
public void setIntHeader(java.lang.String name, int value)
setIntHeader
in interface javax.servlet.http.HttpServletResponse
setIntHeader
in class javax.servlet.http.HttpServletResponseWrapper
public java.util.Collection<Header<? extends java.io.Serializable>> getAllHeaders()
public void addCookie(javax.servlet.http.Cookie cookie)
addCookie
in interface javax.servlet.http.HttpServletResponse
addCookie
in class javax.servlet.http.HttpServletResponseWrapper
public java.util.Collection<javax.servlet.http.Cookie> getCookies()
public void flushBuffer() throws java.io.IOException
flushBuffer
in interface javax.servlet.ServletResponse
flushBuffer
in class javax.servlet.ServletResponseWrapper
java.io.IOException
public void reset()
reset
in interface javax.servlet.ServletResponse
reset
in class javax.servlet.ServletResponseWrapper
public void flush() throws java.io.IOException
java.io.IOException
public boolean isDisableFlushBuffer()
public void setDisableFlushBuffer(boolean disable)
disable
- true if the wrapped reponse's buffer flushing should be disabled