public class ResponseWrapper extends java.lang.Object implements ServletResponse
Modifier and Type | Field and Description |
---|---|
protected HttpServletResponse |
_response |
Constructor and Description |
---|
ResponseWrapper()
Create a new ServletResponseWrapper, wrapping a specified response.
|
ResponseWrapper(HttpServletResponse response)
Create a new ServletResponseWrapper, wrapping a specified response.
|
Modifier and Type | Method and Description |
---|---|
void |
addCookie(Cookie cookie)
Sends a new cookie to the client.
|
void |
addDateHeader(java.lang.String name,
long date)
Adds a header by converting a date to a string.
|
void |
addFooter(java.lang.String key,
java.lang.String value) |
void |
addHeader(java.lang.String name,
java.lang.String value)
Adds a header.
|
void |
addIntHeader(java.lang.String name,
int value)
Adds a header by converting an integer value to a string.
|
boolean |
containsHeader(java.lang.String name)
Returns true if the output headers include
name |
void |
disable()
Disables the response
|
void |
enable()
Enables the response
|
java.lang.String |
encodeRedirectUrl(java.lang.String url)
Deprecated.
|
java.lang.String |
encodeRedirectURL(java.lang.String name)
Encodes session information in a URL suitable for
sendRedirect() |
java.lang.String |
encodeUrl(java.lang.String url)
Deprecated.
|
java.lang.String |
encodeURL(java.lang.String url)
Encodes session information in a URL.
|
void |
flushBuffer()
Flushes the buffer to the client.
|
AbstractHttpResponse |
getAbstractHttpResponse() |
int |
getBufferSize()
Returns the size of the output buffer.
|
java.lang.String |
getCharacterEncoding()
Returns the character encoding the response is using for output.
|
java.lang.String |
getContentType()
Returns the content type
|
java.util.Locale |
getLocale()
Returns the output locale.
|
ServletOutputStream |
getOutputStream()
Returns an output stream for writing to the client.
|
ServletResponse |
getResponse()
Gets the wrapped response
|
java.io.PrintWriter |
getWriter()
Returns a PrintWriter with the proper character encoding for writing
text data to the client.
|
boolean |
isCaching() |
boolean |
isCommitted()
Returns true if some data has actually been send to the client.
|
boolean |
isDisabled()
Returns true if the response is disabled
|
void |
reset()
Resets the output stream, clearing headers and the output buffer.
|
void |
resetBuffer()
Resets the output stream without clearing headers and the output buffer.
|
void |
sendError(int sc)
Sends an HTTP error page based on the status code
|
void |
sendError(int sc,
java.lang.String msg)
Sends an HTTP error page based on the status code
|
void |
sendRedirect(java.lang.String location)
Redirects the client to another page.
|
void |
setBufferSize(int size)
Sets the output buffer size to
size . |
void |
setCacheInvocation(AbstractCacheFilterChain cacheFilterChain) |
void |
setCharacterEncoding(java.lang.String encoding)
Sets the character encoding the response is using for output.
|
void |
setContentLength(int len)
Deprecated.
|
void |
setContentType(java.lang.String type)
Sets the response content type.
|
void |
setDateHeader(java.lang.String name,
long date)
Sets a header by converting a date to a string.
|
void |
setFooter(java.lang.String key,
java.lang.String value) |
void |
setHeader(java.lang.String name,
java.lang.String value)
Sets a header.
|
void |
setIntHeader(java.lang.String name,
int value)
Sets a header by converting an integer value to a string.
|
void |
setLocale(java.util.Locale locale)
Sets the output locale.
|
void |
setMatchCacheEntry(AbstractCacheEntry cacheEntry) |
void |
setResponse(HttpServletResponse response)
Sets the response to be wrapped.
|
void |
setStatus(int sc)
Sets the HTTP status
|
void |
setStatus(int sc,
java.lang.String msg) |
protected HttpServletResponse _response
public ResponseWrapper()
public ResponseWrapper(HttpServletResponse response)
response
- the response to wrap.public void setResponse(HttpServletResponse response)
response
- the response to wrap.public ServletResponse getResponse()
public AbstractHttpResponse getAbstractHttpResponse()
public void setContentType(java.lang.String type)
getWriter()
so the writer can use the
proper character encoding.
To set the output character encoding to ISO-8859-2, use the
following:
response.setContentType("text/html; charset=ISO-8859-2");
setContentType
in interface ServletResponse
type
- the mime type of the outputpublic java.lang.String getContentType()
getContentType
in interface ServletResponse
public java.lang.String getCharacterEncoding()
getCharacterEncoding
in interface ServletResponse
public void setCharacterEncoding(java.lang.String encoding)
setCharacterEncoding
in interface ServletResponse
public void setLocale(java.util.Locale locale)
setLocale
in interface ServletResponse
public java.util.Locale getLocale()
getLocale
in interface ServletResponse
public ServletOutputStream getOutputStream() throws java.io.IOException
getOutputStream
in interface ServletResponse
java.io.IOException
public java.io.PrintWriter getWriter() throws java.io.IOException
getWriter
in interface ServletResponse
java.io.IOException
public void setBufferSize(int size)
size
. The servlet engine
may round the size up.setBufferSize
in interface ServletResponse
size
- the new output buffer size.public int getBufferSize()
getBufferSize
in interface ServletResponse
public void flushBuffer() throws java.io.IOException
flushBuffer
in interface ServletResponse
java.io.IOException
public boolean isCommitted()
isCommitted
in interface ServletResponse
public void reset()
reset()
after data has been committed is illegal.reset
in interface ServletResponse
java.lang.IllegalStateException
- if isCommitted()
is true.public void resetBuffer()
resetBuffer()
after data has been committed is
illegal.resetBuffer
in interface ServletResponse
java.lang.IllegalStateException
- if isCommitted()
is true.public void setContentLength(int len)
setContentLength
in interface ServletResponse
public void setStatus(int sc)
sc
- the HTTP status codepublic void sendError(int sc, java.lang.String msg) throws java.io.IOException
sc
- the HTTP status codejava.io.IOException
public void sendError(int sc) throws java.io.IOException
sc
- the HTTP status codejava.io.IOException
public void sendRedirect(java.lang.String location) throws java.io.IOException
location
- the location to redirect to.java.io.IOException
public void setHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuepublic void addHeader(java.lang.String name, java.lang.String value)
name
- the header namevalue
- the header valuepublic boolean containsHeader(java.lang.String name)
name
name
- the header name to testpublic void setDateHeader(java.lang.String name, long date)
To set the page to expire in 15 seconds use the following:
long now = System.currentTime();
_response.setDateHeader("Expires", now + 15000);
name
- name of the headerdate
- the date in milliseconds since the epoch.public void addDateHeader(java.lang.String name, long date)
name
- name of the headerdate
- the date in milliseconds since the epoch.public void setIntHeader(java.lang.String name, int value)
name
- name of the headervalue
- the value as an integerpublic void addIntHeader(java.lang.String name, int value)
name
- name of the headervalue
- the value as an integerpublic void addCookie(Cookie cookie)
public java.lang.String encodeURL(java.lang.String url)
url
- the url to encodepublic java.lang.String encodeRedirectURL(java.lang.String name)
sendRedirect()
url
- the url to encodepublic void setStatus(int sc, java.lang.String msg)
public java.lang.String encodeUrl(java.lang.String url)
public java.lang.String encodeRedirectUrl(java.lang.String url)
public void setFooter(java.lang.String key, java.lang.String value)
public void addFooter(java.lang.String key, java.lang.String value)
public void disable()
public void enable()
public boolean isDisabled()
public void setMatchCacheEntry(AbstractCacheEntry cacheEntry)
public void setCacheInvocation(AbstractCacheFilterChain cacheFilterChain)
public boolean isCaching()