org.apache.catalina.connector
public class Response extends Object implements HttpServletResponse
Version: $Revision: 832206 $ $Date: 2009-11-03 00:52:06 +0100 (Tue, 03 Nov 2009) $
Field Summary | |
---|---|
protected boolean | appCommitted
The application commit flag. |
protected Connector | connector
Associated Catalina connector. |
protected ArrayList | cookies
The set of Cookies associated with this Response. |
protected Response | coyoteResponse
Coyote response. |
protected boolean | error
The error flag. |
protected ResponseFacade | facade
The facade associated with this response. |
protected SimpleDateFormat | format
The date format we will use for creating date headers. |
protected boolean | included
The included flag. |
protected static String | info
Descriptive information about this Response implementation. |
protected OutputBuffer | outputBuffer
The associated output buffer. |
protected CoyoteOutputStream | outputStream
The associated output stream. |
protected CharChunk | redirectURLCC
Recyclable buffer to hold the redirect URL. |
protected Request | request
The request with which this response is associated. |
protected static StringManager | sm
The string manager for this package. |
protected UEncoder | urlEncoder
URL encoder. |
protected boolean | usingOutputStream
Using output stream flag. |
protected boolean | usingWriter
Using writer flag. |
protected CoyoteWriter | writer
The associated writer. |
Constructor Summary | |
---|---|
Response() |
Method Summary | |
---|---|
void | addCookie(Cookie cookie)
Add the specified Cookie to those that will be included with
this Response.
|
void | addCookieInternal(Cookie cookie)
Add the specified Cookie to those that will be included with
this Response.
|
void | addCookieInternal(Cookie cookie, boolean httpOnly)
Add the specified Cookie to those that will be included with
this Response.
|
void | addDateHeader(String name, long value)
Add the specified date header to the specified value.
|
void | addHeader(String name, String value)
Add the specified header to the specified value.
|
void | addIntHeader(String name, int value)
Add the specified integer header to the specified value.
|
void | clearEncoders()
Clear cached encoders (to save memory for Comet requests). |
boolean | containsHeader(String name)
Has the specified header been set already in this response?
|
ServletOutputStream | createOutputStream()
Create and return a ServletOutputStream to write the content
associated with this Response.
|
String | encodeRedirectUrl(String url)
Encode the session identifier associated with this response
into the specified redirect URL, if necessary.
|
String | encodeRedirectURL(String url)
Encode the session identifier associated with this response
into the specified redirect URL, if necessary.
|
String | encodeUrl(String url)
Encode the session identifier associated with this response
into the specified URL, if necessary.
|
String | encodeURL(String url)
Encode the session identifier associated with this response
into the specified URL, if necessary.
|
void | finishResponse()
Perform whatever actions are required to flush and close the output
stream or writer, in a single operation.
|
void | flushBuffer()
Flush the buffer and commit this response.
|
int | getBufferSize()
Return the actual buffer size used for this Response. |
String | getCharacterEncoding()
Return the character encoding used for this Response. |
Connector | getConnector()
Return the Connector through which this Request was received. |
int | getContentCount()
Return the number of bytes actually written to the output stream. |
long | getContentCountLong()
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. |
String | getContentType()
Return the content type that was set or calculated for this response,
or null if no content type was set. |
Context | getContext()
Return the Context within which this Request is being processed. |
Cookie[] | getCookies()
Return an array of all cookies set for this response, or
a zero-length array if no cookies have been set. |
Response | getCoyoteResponse()
Get the Coyote response. |
String | getHeader(String name)
Return the value for the specified header, or null if this
header has not been set. |
String[] | getHeaderNames()
Return an array of all the header names set for this response, or
a zero-length array if no headers have been set. |
String[] | getHeaderValues(String name)
Return an array of all the header values associated with the
specified header name, or an zero-length array if there are no such
header values.
|
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> . |
Locale | getLocale()
Return the Locale assigned to this response. |
String | getMessage()
Return the error message that was set with sendError()
for this Response. |
ServletOutputStream | getOutputStream()
Return the servlet output stream associated with 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. |
HttpServletResponse | 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. |
PrintWriter | getWriter()
Return the writer associated with this Response.
|
boolean | isAppCommitted()
Application commit flag accessor. |
boolean | isClosed()
Closed flag accessor. |
boolean | isCommitted()
Has the output of this response already been committed? |
protected boolean | isEncodeable(String location)
Return true if the specified URL should be encoded with
a session identifier. |
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()
Clear any content written to the buffer.
|
void | reset(int status, String message)
Reset this response, and specify the values for the HTTP status code
and corresponding message.
|
void | resetBuffer()
Reset the data buffer but not any status or header information.
|
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 | sendError(int status)
Send an error response with the specified status and a
default message.
|
void | sendError(int status, String message)
Send an error response with the specified status and message.
|
void | sendRedirect(String location)
Send a temporary redirect to the specified redirect location URL.
|
void | setAppCommitted(boolean appCommitted)
Set the application commit flag.
|
void | setBufferSize(int size)
Set the buffer size to be used for this Response.
|
void | setCharacterEncoding(String charset) |
void | setConnector(Connector connector)
Set the Connector through which this Request was received.
|
void | setContentLength(int length)
Set the content length (in bytes) for this Response.
|
void | setContentType(String type)
Set the content type for this Response.
|
void | setContext(Context context)
Set the Context within which this Request is being processed. |
void | setCoyoteResponse(Response coyoteResponse)
Set the Coyote response.
|
void | setDateHeader(String name, long value)
Set the specified date header to the specified value.
|
void | setError()
Set the error flag. |
void | setHeader(String name, String value)
Set the specified header to the specified value.
|
void | setIncluded(boolean included)
Set the "processing inside an include" flag.
|
void | setIntHeader(String name, int value)
Set the specified integer header to the specified value.
|
void | setLocale(Locale locale)
Set the Locale that is appropriate for this response, including
setting the appropriate character encoding.
|
void | setRequest(Request request)
Set the Request with which this Response is associated.
|
void | setStatus(int status)
Set the HTTP status to be returned with this response.
|
void | setStatus(int status, String message)
Set the HTTP status and message to be returned with this response.
|
void | setStream(OutputStream stream)
Set the output stream associated with this Response.
|
void | setSuspended(boolean suspended)
Set the suspended flag.
|
protected String | toEncoded(String url, String sessionId)
Return the specified URL with the specified session identifier
suitably encoded.
|
Parameters: cookie Cookie to be added
Parameters: cookie Cookie to be added
Parameters: cookie Cookie to be added httpOnly Should the httpOnly falg be set on this cookie
Parameters: name Name of the header to set value Date value to be set
Parameters: name Name of the header to set value Value to be set
Parameters: name Name of the header to set value Integer value to be set
Parameters: name Name of the header to check
Throws: IOException if an input/output error occurs
Deprecated: As of Version 2.1 of the Java Servlet API, use
encodeRedirectURL()
instead.
Parameters: url URL to be encoded
Parameters: url URL to be encoded
Deprecated: As of Version 2.1 of the Java Servlet API, use
encodeURL()
instead.
Parameters: url URL to be encoded
Parameters: url URL to be encoded
Throws: IOException if an input/output error occurs
Throws: IOException if an input/output error occurs
null
if no content type was set.null
if this
header has not been set. If more than one value was added for this
name, only the first is returned; use getHeaderValues() to retrieve all
of them.
Parameters: name Header name to look up
Parameters: name Header name to look up
<description>/<version>
.sendError()
for this Response.Throws: IllegalStateException if getWriter
has
already been called for this response IOException if an input/output error occurs
Returns: Writer which can be used for error reports. If the response is not an error report returned using sendError or triggered by an unexpected exception thrown during the servlet processing (and only in that case), null will be returned if the response stream has already been used.
Throws: IOException if an input/output error occurs
ServletResponse
for which this object
is the facade.Throws: IllegalStateException if getOutputStream
has
already been called for this response IOException if an input/output error occurs
true
if the specified URL should be encoded with
a session identifier. This will be true if all of the following
conditions are met:
Parameters: location Absolute URL to be validated
Throws: IllegalStateException if this response has already been committed
Throws: IllegalStateException if this response has already been committed
Throws: IllegalStateException if the response has already been committed
Parameters: resetWriterStreamFlags true
if the internal
usingWriter
, usingOutputStream
,
isCharacterEncodingSet
flags should also be reset
Throws: IllegalStateException if the response has already been committed
Throws: IOException if an input/output error occurs
Parameters: status HTTP status code to send
Throws: IllegalStateException if this response has already been committed IOException if an input/output error occurs
Parameters: status HTTP status code to send message Corresponding message to send
Throws: IllegalStateException if this response has already been committed IOException if an input/output error occurs
Parameters: location Location URL to redirect to
Throws: IllegalStateException if this response has already been committed IOException if an input/output error occurs
Parameters: appCommitted The new application committed flag value
Parameters: size The new buffer size
Throws: IllegalStateException if this method is called after output has been committed for this response
Parameters: connector The new connector
Parameters: length The new content length
Parameters: type The new content type
getContextPath()
,
and thus enables parsing of the request URI.
Parameters: context The newly associated Context
Parameters: coyoteResponse The Coyote response
Parameters: name Name of the header to set value Date value to be set
Parameters: name Name of the header to set value Value to be set
Parameters: included true
if we are currently inside a
RequestDispatcher.include(), else false
Parameters: name Name of the header to set value Integer value to be set
Parameters: locale The new locale
Parameters: request The new associated request
Parameters: status The new HTTP status
Deprecated: As of Version 2.1 of the Java Servlet API, this method has been deprecated due to the ambiguous meaning of the message parameter.
Set the HTTP status and message to be returned with this response.Parameters: status The new HTTP status message The associated text message
Parameters: stream The new output stream
Parameters: suspended The new suspended flag value
Parameters: url URL to be encoded with the session id sessionId Session id to be included in the encoded URL