public final class HttpServletResponseImpl extends AbstractCauchoResponse implements CauchoResponse
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 |
|---|
HttpServletResponseImpl(HttpServletRequestImpl request,
AbstractHttpResponse response) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(Cookie cookie)
Adds a cookie to the response.
|
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.
|
protected void |
addServletCookie(WebApp webApp) |
void |
close() |
void |
closeImpl() |
boolean |
containsHeader(java.lang.String name)
Returns true if the output headers include
name |
protected Cookie |
createServletCookie(WebApp webApp) |
void |
disable()
Disables the response
|
void |
enable()
Enables the response
|
java.lang.String |
encodeAbsoluteRedirect(java.lang.String url) |
java.lang.String |
encodeRedirectUrl(java.lang.String string)
Deprecated.
|
java.lang.String |
encodeRedirectURL(java.lang.String string)
Encodes session information in a URL suitable for
sendRedirect() |
java.lang.String |
encodeUrl(java.lang.String string)
Deprecated.
|
java.lang.String |
encodeURL(java.lang.String string)
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.
|
AbstractCacheFilterChain |
getCacheInvocation() |
java.lang.String |
getCharacterEncoding()
Gets the character encoding.
|
java.lang.String |
getCharacterEncodingAssigned()
Gets the character encoding assigned by the developer.
|
java.lang.String |
getCharacterEncodingImpl()
Gets the character encoding.
|
java.lang.String |
getContentType()
Gets the content type.
|
java.lang.String |
getContentTypeImpl()
Gets the content type.
|
Cookie |
getCookie(java.lang.String name) |
java.util.ArrayList<Cookie> |
getCookies() |
boolean |
getForbidForward()
Returns true if RequestDispatcher.forward() is disallowed on
this stream.
|
java.lang.String |
getHeader(java.lang.String key)
Retuns value of header with a given name
|
java.util.Collection<java.lang.String> |
getHeaderNames()
Returns an Iterable for header names set via
HttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long), HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or HttpServletResponse.addIntHeader(java.lang.String, int), respectively. |
java.util.Collection<java.lang.String> |
getHeaders(java.lang.String name)
Returns an Iterable for header values with a given name
|
java.util.Locale |
getLocale()
Returns the output locale.
|
ServletOutputStream |
getOutputStream()
Returns an output stream for writing to the client.
|
boolean |
getPrivateCache()
Returns the value of the private cache.
|
int |
getRemaining() |
HttpServletRequestImpl |
getRequest() |
ServletResponse |
getResponse()
Return wrapped response
|
AbstractResponseStream |
getResponseStream() |
java.lang.String |
getSessionId() |
int |
getStatus()
Returns the current status code of this response
|
java.lang.String |
getStatusMessage() |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter with the proper character encoding for writing
text data to the client.
|
boolean |
hasError() |
boolean |
isCacheControl()
True if the application has a set a cache-control directive
that Resin doesn't understand.
|
boolean |
isCaching() |
boolean |
isCauchoResponseStream() |
boolean |
isCommitted()
Returns true if some data has actually been send to the client.
|
boolean |
isDisableCache() |
boolean |
isDisabled()
Returns true if the response is disabled
|
boolean |
isForwardEnclosed() |
boolean |
isNoCache()
Returns true if the page is non-cacheable
|
boolean |
isNoCacheUnlessVary()
Return true if no-cache without var.
|
boolean |
isPrivateCache()
Returns true if the response should contain a Cache-Control: private
|
void |
killCache()
Set if the page is non-cacheable.
|
void |
reset()
Resets the output stream, clearing headers and the output buffer.
|
void |
resetBuffer()
Resets the output stream, clearing headers and the output buffer.
|
void |
sendError(int code)
Sends an HTTP error page based on the status code
|
void |
sendError(int code,
java.lang.String value)
Sends an HTTP error to the browser.
|
void |
sendRedirect(java.lang.String url)
Sends a redirect to the browser.
|
void |
setBufferSize(int size)
Sets the output buffer size to
size. |
void |
setCacheControl(boolean isCacheControl)
True if the application has a set a cache-control directive
that Resin doesn't understand.
|
void |
setCacheInvocation(AbstractCacheFilterChain cacheInvocation)
Sets the cache invocation to indicate that the response might be
cacheable.
|
void |
setCharacterEncoding(java.lang.String encoding)
Sets the character encoding.
|
void |
setContentLength(int len)
Explicitly sets the length of the result value.
|
void |
setContentLength(long length)
Explicitly sets the length of the result value.
|
void |
setContentType(java.lang.String value)
Sets the browser 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 |
setForbidForward(boolean forbid)
When set to true, RequestDispatcher.forward() is disallowed on
this stream.
|
void |
setForwardEnclosed(boolean isForwardEnclosed) |
void |
setHasError(boolean error) |
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 |
setNoCache(boolean isNoCache)
Set if the page is non-cacheable.
|
void |
setNoCacheUnlessVary(boolean isNoCacheUnlessVary)
Set no cache w/o vary
|
void |
setPrivateCache(boolean isPrivate)
Sets true if the cache is only for the browser, but not
Resin's cache or proxies.
|
void |
setPrivateOrResinCache(boolean isPrivate)
Sets true if the cache is only for the browser and
Resin's cache but not proxies.
|
void |
setResponseStream(AbstractResponseStream responseStream) |
void |
setSessionId(java.lang.String id) |
void |
setStatus(int code)
Sets the HTTP status
|
void |
setStatus(int code,
java.lang.String message)
Sets the HTTP status
|
java.lang.String |
toString() |
completeCache, writeHeadersclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitcompleteCache, writeHeaderspublic HttpServletResponseImpl(HttpServletRequestImpl request, AbstractHttpResponse response)
public HttpServletRequestImpl getRequest()
public ServletOutputStream getOutputStream() throws java.io.IOException
getOutputStream in interface ServletResponsejava.io.IOExceptionpublic java.io.PrintWriter getWriter()
throws java.io.IOException
getWriter in interface ServletResponsejava.io.IOExceptionpublic void setBufferSize(int size)
size. The servlet engine
may round the size up.setBufferSize in interface ServletResponsesize - the new output buffer size.public int getBufferSize()
getBufferSize in interface ServletResponsepublic int getRemaining()
public void flushBuffer()
throws java.io.IOException
flushBuffer in interface ServletResponsejava.io.IOExceptionpublic final boolean isCommitted()
isCommitted in interface ServletResponsepublic void reset()
reset() after data has been committed is illegal.reset in interface ServletResponsejava.lang.IllegalStateException - if isCommitted() is true.public void resetBuffer()
reset() after data has been committed is illegal.resetBuffer in interface ServletResponsejava.lang.IllegalStateException - if isCommitted() is true.public void setContentLength(int len)
setContentLength in interface ServletResponsepublic void setContentLength(long length)
setContentLength in interface CauchoResponsepublic void disable()
public void enable()
public boolean isDisabled()
public void setLocale(java.util.Locale locale)
ServletResponsesetLocale in interface ServletResponsepublic java.util.Locale getLocale()
ServletResponsegetLocale in interface ServletResponsepublic void setPrivateCache(boolean isPrivate)
Since proxy caching also caches headers, cached pages with session ids can't be cached in the browser. XXX: but doesn't this just mean that Resin shouldn't send the session information back if the page is cached? Because a second request where everything is identical would see the same response except for the cookies.
setPrivateCache in interface CauchoResponsepublic void setPrivateOrResinCache(boolean isPrivate)
public void setCacheInvocation(AbstractCacheFilterChain cacheInvocation)
setCacheInvocation in interface CauchoResponsepublic final AbstractCacheFilterChain getCacheInvocation()
public boolean isCaching()
isCaching in interface CauchoResponsepublic void setNoCacheUnlessVary(boolean isNoCacheUnlessVary)
public boolean isNoCacheUnlessVary()
isNoCacheUnlessVary in interface CauchoResponsepublic boolean getPrivateCache()
public boolean isPrivateCache()
public boolean isCacheControl()
public void setCacheControl(boolean isCacheControl)
public void setNoCache(boolean isNoCache)
setNoCache in interface CauchoResponsepublic boolean isNoCache()
public void killCache()
killCache in interface CauchoResponsepublic boolean isDisableCache()
public void setStatus(int code)
setStatus in interface HttpServletResponsecode - the HTTP status codepublic void setStatus(int code,
java.lang.String message)
setStatus in interface HttpServletResponsecode - the HTTP status codemessage - the HTTP status messagepublic void sendError(int code)
throws java.io.IOException
sendError in interface HttpServletResponsecode - the HTTP status codejava.io.IOExceptionpublic void sendError(int code,
java.lang.String value)
throws java.io.IOException
sendError in interface HttpServletResponsecode - the HTTP error codevalue - a string messagejava.io.IOExceptionpublic void setContentType(java.lang.String value)
For example, to set the output encoding to use UTF-8 instead of
the default ISO-8859-1 (Latin-1), use the following:
setContentType("text/html; charset=UTF-8");
setContentType in interface ServletResponsevalue - the mime type of the outputpublic java.lang.String getContentType()
getContentType in interface ServletResponsepublic java.lang.String getContentTypeImpl()
public java.lang.String getCharacterEncodingAssigned()
getCharacterEncodingAssigned in interface CauchoResponsegetCharacterEncodingAssigned in class AbstractCauchoResponsepublic java.lang.String getCharacterEncoding()
getCharacterEncoding in interface ServletResponsepublic java.lang.String getCharacterEncodingImpl()
public void setCharacterEncoding(java.lang.String encoding)
setCharacterEncoding in interface ServletResponsepublic void sendRedirect(java.lang.String url)
throws java.io.IOException
sendRedirect in interface HttpServletResponseurl - the possibly relative url to send to the browserjava.io.IOExceptionpublic java.lang.String encodeAbsoluteRedirect(java.lang.String url)
public void setHeader(java.lang.String name,
java.lang.String value)
setHeader in interface HttpServletResponsename - the header namevalue - the header valuepublic void addHeader(java.lang.String name,
java.lang.String value)
addHeader in interface HttpServletResponsename - the header namevalue - the header valuepublic boolean containsHeader(java.lang.String name)
namecontainsHeader in interface HttpServletResponsename - 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);
setDateHeader in interface HttpServletResponsename - name of the headerdate - the date in milliseconds since the epoch.public void addDateHeader(java.lang.String name,
long date)
addDateHeader in interface HttpServletResponsename - name of the headerdate - the date in milliseconds since the epoch.public void setIntHeader(java.lang.String name,
int value)
setIntHeader in interface HttpServletResponsename - name of the headervalue - the value as an integerpublic void addIntHeader(java.lang.String name,
int value)
addIntHeader in interface HttpServletResponsename - name of the headervalue - the value as an integerpublic void addCookie(Cookie cookie)
addCookie in interface HttpServletResponsecookie - the response cookiepublic Cookie getCookie(java.lang.String name)
public java.util.ArrayList<Cookie> getCookies()
public java.lang.String getSessionId()
public void setSessionId(java.lang.String id)
setSessionId in interface CauchoResponseprotected void addServletCookie(WebApp webApp)
public java.lang.String encodeURL(java.lang.String string)
encodeURL in interface HttpServletResponsestring - the url to encodepublic java.lang.String encodeRedirectURL(java.lang.String string)
HttpServletResponsesendRedirect()encodeRedirectURL in interface HttpServletResponsestring - the url to encodepublic java.lang.String encodeRedirectUrl(java.lang.String string)
encodeRedirectUrl in interface HttpServletResponsepublic java.lang.String encodeUrl(java.lang.String string)
encodeUrl in interface HttpServletResponsepublic AbstractResponseStream getResponseStream()
getResponseStream in interface CauchoResponsepublic void setResponseStream(AbstractResponseStream responseStream)
setResponseStream in interface CauchoResponsepublic boolean isCauchoResponseStream()
isCauchoResponseStream in interface CauchoResponsepublic java.lang.String getHeader(java.lang.String key)
HttpServletResponsegetHeader in interface CauchoResponsegetHeader in interface HttpServletResponsepublic void setFooter(java.lang.String key,
java.lang.String value)
setFooter in interface CauchoResponsepublic void addFooter(java.lang.String key,
java.lang.String value)
addFooter in interface CauchoResponsepublic void close()
throws java.io.IOException
close in interface CauchoResponsejava.io.IOExceptionpublic void setForbidForward(boolean forbid)
setForbidForward in interface CauchoResponsepublic boolean getForbidForward()
getForbidForward in interface CauchoResponsepublic boolean hasError()
hasError in interface CauchoResponsepublic void setHasError(boolean error)
setHasError in interface CauchoResponsepublic ServletResponse getResponse()
CauchoResponsegetResponse in interface CauchoResponsepublic AbstractHttpResponse getAbstractHttpResponse()
getAbstractHttpResponse in interface CauchoResponsepublic int getStatus()
HttpServletResponsegetStatus in interface HttpServletResponsepublic java.lang.String getStatusMessage()
getStatusMessage in interface CauchoResponsepublic java.util.Collection<java.lang.String> getHeaders(java.lang.String name)
HttpServletResponsegetHeaders in interface HttpServletResponsepublic java.util.Collection<java.lang.String> getHeaderNames()
HttpServletResponseHttpServletResponse.setHeader(java.lang.String, java.lang.String), HttpServletResponse.addHeader(java.lang.String, java.lang.String), HttpServletResponse.setDateHeader(java.lang.String, long), HttpServletResponse.addDateHeader(java.lang.String, long), HttpServletResponse.setIntHeader(java.lang.String, int), or HttpServletResponse.addIntHeader(java.lang.String, int), respectively.getHeaderNames in interface HttpServletResponsepublic void setForwardEnclosed(boolean isForwardEnclosed)
setForwardEnclosed in interface CauchoResponsepublic boolean isForwardEnclosed()
isForwardEnclosed in interface CauchoResponsepublic void closeImpl()
throws java.io.IOException
java.io.IOExceptionpublic java.lang.String toString()
toString in class AbstractCauchoResponse