|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object | +--com.caucho.server.http.Response
Encapsulates the servlet response, controlling response headers and the response stream.
| Field Summary | |
protected boolean |
allowCache
|
protected boolean |
allowKeepalive
|
protected QDate |
calendar
|
protected CharBuffer |
cb
|
protected java.lang.String |
charEncoding
|
protected long |
contentLength
|
protected java.lang.String |
contentPrefix
|
protected java.lang.String |
contentType
|
protected java.util.ArrayList |
cookiesOut
|
protected boolean |
disableCaching
|
protected boolean |
disableHeaders
|
protected java.lang.String |
filter
|
protected boolean |
forbidForward
|
protected boolean |
hasError
|
protected boolean |
hasMsieHack
|
protected boolean |
hasOutputStream
|
protected boolean |
hasSentLog
|
protected boolean |
hasWriter
|
protected java.util.ArrayList |
headerKeys
|
protected java.util.ArrayList |
headerValues
|
protected boolean |
isChaining
|
protected boolean |
isClosed
|
protected boolean |
isNoCache
|
protected boolean |
isTopCache
|
protected AbstractRequest |
request
|
protected int |
statusCode
|
protected java.lang.String |
statusMessage
|
| Constructor Summary | |
protected |
Response()
|
| Method Summary | |
void |
addCookie(Cookie cookie)
Adds a cookie to the response. |
void |
addDateHeader(java.lang.String key,
long value)
Convenience for adding a date header. |
void |
addHeader(java.lang.String key,
java.lang.String value)
Adds a new header. |
void |
addIntHeader(java.lang.String key,
int value)
Convenience for adding an integer header. |
void |
clearBuffer()
|
void |
close()
Closes the request. |
boolean |
containsHeader(java.lang.String name)
Returns true if the response already contains the named header. |
boolean |
disableCaching(boolean disable)
|
boolean |
disableHeaders(boolean disable)
|
java.lang.String |
encodeRedirectUrl(java.lang.String string)
Deprecated. |
java.lang.String |
encodeRedirectURL(java.lang.String string)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed,
returns the URL unchanged. |
java.lang.String |
encodeUrl(java.lang.String string)
Deprecated. |
java.lang.String |
encodeURL(java.lang.String string)
Encode the URL with the session jd. |
boolean |
fillCookie(CharBuffer cb,
Cookie cookie,
long date,
int version)
Fills the response for a cookie |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
int |
getBufferSize()
Returns the actual buffer size used for the response. |
java.lang.String |
getChain()
|
java.lang.String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response. |
int |
getContentLength()
Returns the number of bytes send to the output. |
Cookie |
getCookie(java.lang.String name)
|
java.util.ArrayList |
getCookies()
|
boolean |
getForbidForward()
Returns true if RequestDispatcher.forward() is disallowed on this stream. |
java.lang.String |
getHeader(java.lang.String name)
Returns the value of an already set output header. |
java.util.Locale |
getLocale()
Returns the locale assigned to the response. |
WriteStream |
getOriginalStream()
|
ServletOutputStream |
getOutputStream()
Returns the ServletOutputStream for the response. |
int |
getRemaining()
|
int |
getStatusCode()
|
WriteStream |
getStream()
Returns the underlying WriteStream beneath the request. |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter for the response. |
boolean |
hasError()
Returns true if we're processing an error. |
protected void |
initChaining()
|
boolean |
isCommitted()
Returns true if some data has been sent to the browser. |
void |
killCache()
Set if the page is non-cacheable. |
void |
removeHeader(java.lang.String key)
|
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code. |
void |
sendError(int code)
Sends an error response to the client using the specified status code and clearing the buffer. |
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 preferred buffer size for the body of the response. |
void |
setContentLength(int length)
Sets the content length of the result. |
void |
setContentType(java.lang.String value)
Sets the browser content type. |
void |
setDateHeader(java.lang.String name,
long value)
Convenience for setting a date header. |
void |
setForbidForward(boolean forbid)
When set to true, RequestDispatcher.forward() is disallowed on this stream. |
void |
setHasError(boolean hasError)
Set to true while processing an error. |
void |
setHeader(java.lang.String key,
java.lang.String value)
Sets a header, replacing an already-existing header. |
void |
setIgnoreClientDisconnect(boolean ignore)
If set true, client disconnect exceptions are no propagated to the server code. |
void |
setIntHeader(java.lang.String name,
int value)
Convenience for setting an integer header. |
void |
setLocale(java.util.Locale locale)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. |
void |
setNoCache(boolean isNoCache)
Set if the page is non-cacheable. |
void |
setSessionId(java.lang.String id)
|
void |
setStatus(int code)
Sets the status code for this response. |
void |
setStatus(int code,
java.lang.String message)
Deprecated. |
void |
setStream(WriteStream os)
Sets the underlying WriteStream beneath the request. |
TempBuffer |
startChaining()
Fix up the stream and headers for the next servlet in the chain. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected AbstractRequest request
protected int statusCode
protected java.lang.String statusMessage
protected java.lang.String contentType
protected java.lang.String contentPrefix
protected java.lang.String charEncoding
protected java.lang.String filter
protected java.util.ArrayList headerKeys
protected java.util.ArrayList headerValues
protected java.util.ArrayList cookiesOut
protected QDate calendar
protected CharBuffer cb
protected boolean allowKeepalive
protected boolean disableHeaders
protected boolean disableCaching
protected long contentLength
protected boolean isChaining
protected boolean isClosed
protected boolean hasSentLog
protected boolean hasWriter
protected boolean hasOutputStream
protected boolean hasMsieHack
protected boolean isNoCache
protected boolean allowCache
protected boolean forbidForward
protected boolean hasError
protected boolean isTopCache
| Constructor Detail |
protected Response()
| Method Detail |
public void setIgnoreClientDisconnect(boolean ignore)
public void close()
throws java.io.IOException
close in interface CauchoResponsepublic void setForbidForward(boolean forbid)
setForbidForward in interface CauchoResponsepublic boolean getForbidForward()
getForbidForward in interface CauchoResponsepublic void setHasError(boolean hasError)
setHasError in interface CauchoResponsepublic boolean hasError()
hasError in interface CauchoResponsepublic java.lang.String getChain()
getChain in interface CauchoResponse
public TempBuffer startChaining()
throws java.io.IOException
headers - new headers for the next request.
public void setStatus(int code,
java.lang.String message)
setStatus in interface HttpServletResponsejavax.servlet.http.HttpServletResponsesc - the status codesm - the status messagepublic void setStatus(int code)
HttpServletResponsesendError method should be used
instead.
The container clears the buffer and sets the Location header, preserving cookies and other headers.
setStatus in interface HttpServletResponsejavax.servlet.http.HttpServletResponsesc - the status codeHttpServletResponse.sendError(int, java.lang.String)public int getStatusCode()
public void sendError(int code,
java.lang.String value)
throws java.io.IOException
sendError in interface HttpServletResponsecode - the HTTP error codevalue - a string message
public void sendError(int code)
throws java.io.IOException
HttpServletResponseIf the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError in interface HttpServletResponsejavax.servlet.http.HttpServletResponsesc - the error status codejava.io.IOException - If an input or output exception occursjava.lang.IllegalStateException - If the response was committed
before this method call
public void sendRedirect(java.lang.String url)
throws java.io.IOException
sendRedirect in interface HttpServletResponseurl - the possibly relative url to send to the browserpublic boolean containsHeader(java.lang.String name)
containsHeader in interface HttpServletResponsename - name of the header to test.public java.lang.String getHeader(java.lang.String name)
getHeader in interface CauchoResponsename - name of the header to get.
public void setHeader(java.lang.String key,
java.lang.String value)
setHeader in interface HttpServletResponsekey - the header key to set.value - the header value to set.
public void addHeader(java.lang.String key,
java.lang.String value)
addHeader in interface CauchoResponsekey - the header key.value - the header value.public void removeHeader(java.lang.String key)
public void setIntHeader(java.lang.String name,
int value)
setIntHeader in interface HttpServletResponsename - the header name.value - an integer to be converted to a string for the header.
public void addIntHeader(java.lang.String key,
int value)
addIntHeader in interface HttpServletResponsename - the header name.value - an integer to be converted to a string for the header.
public void setDateHeader(java.lang.String name,
long value)
setDateHeader in interface HttpServletResponsename - the header name.value - an time in milliseconds to be converted to a date string.
public void addDateHeader(java.lang.String key,
long value)
addDateHeader in interface HttpServletResponsename - the header name.value - an time in milliseconds to be converted to a date string.public void setContentLength(int length)
setContentLength in interface ServletResponselength - the length of the content.public 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 ServletResponsejavax.servlet.ServletResponsetype - a String specifying the MIME
type of the contentServletResponse.getOutputStream(),
ServletResponse.getWriter()public java.lang.String getCharacterEncoding()
ServletResponseIf no charset has been assigned, it is implicitly
set to ISO-8859-1 (Latin-1).
See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.
getCharacterEncoding in interface ServletResponsejavax.servlet.ServletResponseString specifying the
name of the charset, for
example, ISO-8859-1public void addCookie(Cookie cookie)
addCookie in interface HttpServletResponsecookie - the response cookiepublic Cookie getCookie(java.lang.String name)
public java.util.ArrayList getCookies()
public void setSessionId(java.lang.String id)
setSessionId in interface CauchoResponsepublic WriteStream getStream()
getStream in interface CauchoResponsepublic void setStream(WriteStream os)
setStream in interface CauchoResponsepublic WriteStream getOriginalStream()
public ServletOutputStream getOutputStream()
throws java.io.IOException
getOutputStream in interface ServletResponsejavax.servlet.ServletResponseServletOutputStream for writing binary datajava.lang.IllegalStateException - if the getWriter method
has been called on this responsejava.io.IOException - if an input or output exception occurredServletResponse.getWriter()
public java.io.PrintWriter getWriter()
throws java.io.IOException
getWriter in interface ServletResponsejavax.servlet.ServletResponsePrintWriter object that
can return character data to the clientjava.io.UnsupportedEncodingException - if the charset specified in
setContentType cannot be
usedjava.lang.IllegalStateException - if the getOutputStream
method has already been called for this
response objectjava.io.IOException - if an input or output exception occurredServletResponse.getOutputStream(),
ServletResponse.setContentType(java.lang.String)public java.lang.String encodeURL(java.lang.String string)
encodeURL in interface HttpServletResponsestring - the url to be encodedpublic java.lang.String encodeRedirectURL(java.lang.String string)
HttpServletResponsesendRedirect method or, if encoding is not needed,
returns the URL unchanged. The implementation of this method
includes the logic to determine whether the session ID
needs to be encoded in the URL. Because the rules for making
this determination can differ from those used to decide whether to
encode a normal link, this method is seperate from the
encodeURL method.
All URLs sent to the HttpServletResponse.sendRedirect
method should be run through this method. Otherwise, URL
rewriting cannot be used with browsers which do not support
cookies.
encodeRedirectURL in interface HttpServletResponsejavax.servlet.http.HttpServletResponseurl - the url to be encoded.HttpServletResponse.sendRedirect(java.lang.String),
HttpServletResponse.encodeUrl(java.lang.String)public java.lang.String encodeRedirectUrl(java.lang.String string)
encodeRedirectUrl in interface HttpServletResponsejavax.servlet.http.HttpServletResponseurl - the url to be encoded.public java.lang.String encodeUrl(java.lang.String string)
encodeUrl in interface HttpServletResponsejavax.servlet.http.HttpServletResponseurl - the url to be encoded.public void setBufferSize(int size)
ServletResponsegetBufferSize.
A larger buffer allows more content to be written before anything is actually sent, thus providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.
This method must be called before any response body content is
written; if content has been written, this method throws an
IllegalStateException.
setBufferSize in interface CauchoResponsejavax.servlet.ServletResponsesize - the preferred buffer sizejava.lang.IllegalStateException - if this method is called after
content has been writtenServletResponse.getBufferSize(),
ServletResponse.flushBuffer(),
ServletResponse.isCommitted(),
ServletResponse.reset()public int getBufferSize()
ServletResponsegetBufferSize in interface CauchoResponsejavax.servlet.ServletResponseServletResponse.setBufferSize(int),
ServletResponse.flushBuffer(),
ServletResponse.isCommitted(),
ServletResponse.reset()
public void flushBuffer()
throws java.io.IOException
ServletResponseflushBuffer in interface CauchoResponsejavax.servlet.ServletResponseServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.isCommitted(),
ServletResponse.reset()public boolean isCommitted()
isCommitted in interface ServletResponsejavax.servlet.ServletResponseServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.flushBuffer(),
ServletResponse.reset()public void reset()
ServletResponseIllegalStateException.reset in interface CauchoResponsejavax.servlet.ServletResponsejava.lang.IllegalStateException - if the response has already been
committedServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.flushBuffer(),
ServletResponse.isCommitted()public void resetBuffer()
ServletResponseIllegalStateException.resetBuffer in interface ServletResponsejavax.servlet.ServletResponseServletResponse.setBufferSize(int),
ServletResponse.getBufferSize(),
ServletResponse.isCommitted(),
ServletResponse.reset()public void clearBuffer()
clearBuffer in interface CauchoResponsepublic void setLocale(java.util.Locale locale)
ServletResponseServletResponse.getWriter(). By default, the response locale
is the default locale for the server.setLocale in interface ServletResponsejavax.servlet.ServletResponseloc - the locale of the responseServletResponse.getLocale()public java.util.Locale getLocale()
ServletResponsegetLocale in interface ServletResponsejavax.servlet.ServletResponseServletResponse.setLocale(java.util.Locale)public int getRemaining()
getRemaining in interface CauchoResponsepublic int getContentLength()
public boolean disableHeaders(boolean disable)
disableHeaders in interface CauchoResponsepublic boolean disableCaching(boolean disable)
public void setNoCache(boolean isNoCache)
public void killCache()
killCache in interface CauchoResponse
public boolean fillCookie(CharBuffer cb,
Cookie cookie,
long date,
int version)
cb - result buffer to contain the generated stringcookie - the cookiedate - the current dateprotected void initChaining()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||