Implements javax.servlet.HttpServletResponse from the javax.servlet package.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private static PrintWriter | |
| private static ServletOutputStream | |
| private BufferCache. | |
| private String | |
| private HttpConnection | |
| private String | |
| private boolean | |
| private int | |
| private boolean | |
| private Locale | |
| private String | |
| private int | |
| private String | |
| private int | |
| private PrintWriter | |
| public static final int | |
| public static final int | |
| public static String | SET_INCLUDE_HEADER_PREFIX
If a header name starts with this string, the header (stripped of the prefix)
can be set during include using only |
| public static final int | |
| public static final int |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | addCookie(Cookie
the Cookie to return to the client cookie)Implements javax. |
| public void | addDateHeader(String
the name of the header to set name, long the additional date value date)Implements javax. |
| public void | addHeader(String
the name of the header name, String the additional header value If it contains
octet string, it should be encoded
according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt) value)Implements javax. |
| public void | addIntHeader(String
the name of the header name, int the assigned integer value value)Implements javax. |
| public void | |
| public boolean | containsHeader(String
the header name name)Implements javax. |
| public void | |
| public void | |
| public String | encodeRedirectURL(String
the url to be encoded. url)Implements javax. sendRedirect method or, if encoding is not needed,
returns the URL unchanged.
|
| public String | encodeRedirectUrl(String
the url to be encoded. url)Implements javax. |
| public String | encodeURL(String
the url to be encoded. url)Implements javax. |
| public String | encodeUrl(String
the url to be encoded. url)Implements javax. |
| public void | flushBuffer()
Implements javax. |
| public int | getBufferSize()
Implements javax. |
| public String | getCharacterEncoding()
Implements javax. |
| public long | |
| public String | getContentType()
Implements javax. |
| public String | getHeader(String
the name of the response header whose value to return name)Implements javax. |
| public Enumeration | getHeaders(String
the name of the response header whose values to return name)Implements javax. |
| public HttpFields | |
| public Locale | getLocale()
Implements javax. setLocale method.
|
| public ServletOutputStream | getOutputStream()
Implements javax. ServletOutputStream suitable for writing binary
data in the response.
|
| public String | |
| public int | Returns: The HTTP status code that has been set for this request. This will be200Implements javax. |
| public PrintWriter | getWriter()
Implements javax. PrintWriter object that
can send character text to the client.
|
| public boolean | isCommitted()
Implements javax. |
| public boolean | |
| public boolean | |
| protected void | |
| public void | reset()
Implements javax. |
| public void | resetBuffer()
Implements javax. |
| public void | sendError(int
the error status code code, String the descriptive message message)Implements javax. Sends an error response to the client using the specified status and clears the buffer. |
| public void | sendError(int
the error status code sc)Implements javax. |
| public void | |
| public void | sendRedirect(String
the redirect location URL location)Implements javax. |
| public void | setBufferSize(int
the preferred buffer size size)Implements javax. |
| public void | setCharacterEncoding(String
a String specifying only the character set
defined by IANA Character Sets
(http://www.iana.org/assignments/character-sets) encoding)Implements javax. |
| public void | setContentLength(int
an integer specifying the length of the
content being returned to the client; sets the Content-Length header len)Implements javax. |
| public void | setContentType(String
a contentType)String specifying the MIME
type of the contentImplements javax. |
| public void | setDateHeader(String
the name of the header to set name, long the assigned date value date)Implements javax. |
| public void | setHeader(String
the name of the header name, String the header value If it contains octet string,
it should be encoded according to RFC 2047
(http://www.ietf.org/rfc/rfc2047.txt) value)Implements javax. |
| public void | setIntHeader(String
the name of the header name, int the assigned integer value value)Implements javax. |
| public void | setLocale(Locale
the locale of the response locale)Implements javax. |
| public void | |
| public void | setStatus(int
the status code sc)Implements javax. |
| public void | setStatus(int
the status code sc, String the status message sm)Implements javax. |
| public String |
| __nullPrintWriter | back to summary |
|---|---|
| private static PrintWriter __nullPrintWriter | |
| __nullServletOut | back to summary |
|---|---|
| private static ServletOutputStream __nullServletOut | |
| _cachedMimeType | back to summary |
|---|---|
| private BufferCache. | |
| _characterEncoding | back to summary |
|---|---|
| private String _characterEncoding | |
| _connection | back to summary |
|---|---|
| private HttpConnection _connection | |
| _contentType | back to summary |
|---|---|
| private String _contentType | |
| _disabled | back to summary |
|---|---|
| private boolean _disabled | |
| _disabledOutputState | back to summary |
|---|---|
| private int _disabledOutputState | |
| _explicitEncoding | back to summary |
|---|---|
| private boolean _explicitEncoding | |
| _locale | back to summary |
|---|---|
| private Locale _locale | |
| _mimeType | back to summary |
|---|---|
| private String _mimeType | |
| _outputState | back to summary |
|---|---|
| private int _outputState | |
| _reason | back to summary |
|---|---|
| private String _reason | |
| _status | back to summary |
|---|---|
| private int _status | |
| _writer | back to summary |
|---|---|
| private PrintWriter _writer | |
| DISABLED | back to summary |
|---|---|
| public static final int DISABLED | |
| NONE | back to summary |
|---|---|
| public static final int NONE | |
| SET_INCLUDE_HEADER_PREFIX | back to summary |
|---|---|
| public static String SET_INCLUDE_HEADER_PREFIX If a header name starts with this string, the header (stripped of the prefix)
can be set during include using only | |
| STREAM | back to summary |
|---|---|
| public static final int STREAM | |
| WRITER | back to summary |
|---|---|
| public static final int WRITER | |
| Response | back to summary |
|---|---|
| public Response(HttpConnection connection) | |
| addCookie | back to summary |
|---|---|
| public void addCookie(Cookie cookie) Implements javax. Doc from javax. Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.
| |
| addDateHeader | back to summary |
|---|---|
| public void addDateHeader(String name, long date) Implements javax. Doc from javax. Adds a response header with the given name and date-value. The date is specified in terms of milliseconds since the epoch. This method allows response headers to have multiple values.
| |
| addHeader | back to summary |
|---|---|
| public void addHeader(String name, String value) Implements javax. Doc from javax. Adds a response header with the given name and value. This method allows response headers to have multiple values. | |
| addIntHeader | back to summary |
|---|---|
| public void addIntHeader(String name, int value) Implements javax. Doc from javax. Adds a response header with the given name and integer value. This method allows response headers to have multiple values.
| |
| complete | back to summary |
|---|---|
| public void complete() throws IOException | |
| containsHeader | back to summary |
|---|---|
| public boolean containsHeader(String name) Implements javax. Doc from javax. Returns a boolean indicating whether the named response header has already been set.
| |
| disable | back to summary |
|---|---|
| public void disable() | |
| enable | back to summary |
|---|---|
| public void enable() | |
| encodeRedirectURL | back to summary |
|---|---|
| public String encodeRedirectURL(String url) Implements javax. Doc from javax. Encodes the specified URL for use in the
All URLs sent to the If the URL is relative, it is always relative to the current HttpServletRequest. | |
| encodeRedirectUrl | back to summary |
|---|---|
| public String encodeRedirectUrl(String url) Implements javax.
| |
| encodeURL | back to summary |
|---|---|
| public String encodeURL(String url) Implements javax. Doc from javax. Encodes the specified URL by including the session ID, 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. For example, if the browser supports cookies, or session tracking is turned off, URL encoding is unnecessary. For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies. If the URL is relative, it is always relative to the current HttpServletRequest. | |
| encodeUrl | back to summary |
|---|---|
| public String encodeUrl(String url) Implements javax.
| |
| flushBuffer | back to summary |
|---|---|
| public void flushBuffer() throws IOException Implements javax. Doc from javax. Forces any content in the buffer to be written to the client. A call to this method automatically commits the response, meaning the status code and headers will be written.
| |
| getBufferSize | back to summary |
|---|---|
| public int getBufferSize() Implements javax. Doc from javax. Returns the actual buffer size used for the response. If no buffering is used, this method returns 0.
| |
| getCharacterEncoding | back to summary |
|---|---|
| public String getCharacterEncoding() Implements javax. Doc from javax. Returns the name of the character encoding (MIME charset)
used for the body sent in this response.
The following methods for specifying the response character encoding are
consulted, in decreasing order of priority: per request, perweb-app
(using See RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) for more information about character encoding and MIME.
| |
| getContentCount | back to summary |
|---|---|
public long getContentCount()
| |
| getContentType | back to summary |
|---|---|
| public String getContentType() Implements javax. Doc from javax. Returns the content type used for the MIME body
sent in this response. The content type proper must
have been specified using
| |
| getHeader | back to summary |
|---|---|
| public String getHeader(String name) Implements javax. Doc from javax. Gets the value of the response header with the given name. If a response header with the given name exists and contains multiple values, the value that was added first will be returned. This method considers only response headers set or added via
| |
| getHeaders | back to summary |
|---|---|
| public Enumeration Implements javax. Doc from javax. Gets the values of the response header with the given name. This method considers only response headers set or added via
Any changes to the returned
| |
| getHttpFields | back to summary |
|---|---|
| public HttpFields getHttpFields() | |
| getLocale | back to summary |
|---|---|
| public Locale getLocale() Implements javax. Doc from javax. Returns the locale specified for this response
using the
| |
| getOutputStream | back to summary |
|---|---|
| public ServletOutputStream getOutputStream() throws IOException Implements javax. Doc from javax. Returns a Calling flush() on the ServletOutputStream commits the response.
Either this method or
| |
| getReason | back to summary |
|---|---|
| public String getReason() | |
| getStatus | back to summary |
|---|---|
| public int getStatus() Implements javax. Doc from javax. Gets the current status code of this response.
| |
| getWriter | back to summary |
|---|---|
| public PrintWriter getWriter() throws IOException Implements javax. Doc from javax. Returns a Calling flush() on the Either this method or
| |
| isCommitted | back to summary |
|---|---|
| public boolean isCommitted() Implements javax. Doc from javax. Returns a boolean indicating if the response has been committed. A committed response has already had its status code and headers written.
| |
| isDisabled | back to summary |
|---|---|
| public boolean isDisabled() | |
| isWriting | back to summary |
|---|---|
| public boolean isWriting() | |
| recycle | back to summary |
|---|---|
| protected void recycle() | |
| reset | back to summary |
|---|---|
| public void reset() Implements javax. Doc from javax. Clears any data that exists in the buffer as well as the status code,
headers. The state of calling | |
| resetBuffer | back to summary |
|---|---|
| public void resetBuffer() Implements javax. Doc from javax. Clears the content of the underlying buffer in the response without
clearing headers or status code. If the
response has been committed, this method throws an
| |
| sendError | back to summary |
|---|---|
| public void sendError(int code, String message) throws IOException Implements javax. Doc from javax. Sends an error response to the client using the specified status and clears the buffer. The server defaults to creating the response to look like an HTML-formatted server error page containing the specified message, setting the content type to "text/html". The caller is not responsible for escaping or re-encoding the message to ensure it is safe with respect to the current response encoding and content type. This aspect of safety is the responsibility of the container, as it is generating the error page containing the message. The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back in preference to the suggested msg parameter and the msg parameter will be ignored. If 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 | back to summary |
|---|---|
| public void sendError(int sc) throws IOException Implements javax. Doc from javax. Sends an error response to the client using the specified status code and clears the buffer. The server will preserve cookies and may clear or update any headers needed to serve the error page as a valid response. If an error-page declaration has been made for the web application corresponding to the status code passed in, it will be served back the error page If 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.
| |
| sendProcessing | back to summary |
|---|---|
| public void sendProcessing() throws IOException | |
| sendRedirect | back to summary |
|---|---|
| public void sendRedirect(String location) throws IOException Implements javax. Doc from javax. Sends a temporary redirect response to the client using the
specified redirect location URL and clears the buffer. The buffer will
be replaced with the data set by this method. Calling this method sets the
status code to If 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.
| |
| setBufferSize | back to summary |
|---|---|
| public void setBufferSize(int size) Implements javax. Doc from javax. Sets the preferred buffer size for the body of the response.
The servlet container will use a buffer at least as large as
the size requested. The actual buffer size used can be found
using 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 or the response object has
been committed, this method throws an
| |
| setCharacterEncoding | back to summary |
|---|---|
| public void setCharacterEncoding(String encoding) Implements javax. Doc from javax. Sets the character encoding (MIME charset) of the response
being sent to the client, for example, to UTF-8.
If the response character encoding has already been set by the
This method can be called repeatedly to change the character
encoding.
This method has no effect if it is called after
Containers must communicate the character encoding used for
the servlet response's writer to the client if the protocol
provides a way for doing so. In the case of HTTP, the character
encoding is communicated as part of the
| |
| setContentLength | back to summary |
|---|---|
| public void setContentLength(int len) Implements javax. Doc from javax. Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.
| |
| setContentType | back to summary |
|---|---|
| public void setContentType(String contentType) Implements javax. Doc from javax. Sets the content type of the response being sent to
the client, if the response has not been committed yet.
The given content type may include a character encoding
specification, for example, This method may be called repeatedly to change content type and
character encoding.
This method has no effect if called after the response
has been committed. It does not set the response's character
encoding if it is called after Containers must communicate the content type and the character
encoding used for the servlet response's writer to the client if
the protocol provides a way for doing so. In the case of HTTP,
the
| |
| setDateHeader | back to summary |
|---|---|
| public void setDateHeader(String name, long date) Implements javax. Doc from javax. Sets a response header with the given name and
date-value. The date is specified in terms of
milliseconds since the epoch. If the header had already
been set, the new value overwrites the previous one. The
| |
| setHeader | back to summary |
|---|---|
| public void setHeader(String name, String value) Implements javax. Doc from javax. Sets a response header with the given name and value.
If the header had already been set, the new value overwrites the
previous one. The | |
| setIntHeader | back to summary |
|---|---|
| public void setIntHeader(String name, int value) Implements javax. Doc from javax. Sets a response header with the given name and
integer value. If the header had already been set, the new value
overwrites the previous one. The
| |
| setLocale | back to summary |
|---|---|
| public void setLocale(Locale locale) Implements javax. Doc from javax. Sets the locale of the response, if the response has not been
committed yet. It also sets the response's character encoding
appropriately for the locale, if the character encoding has not
been explicitly set using This method may be called repeatedly to change locale and
character encoding. The method has no effect if called after the
response has been committed. It does not set the response's
character encoding if it is called after Containers must communicate the locale and the character encoding
used for the servlet response's writer to the client if the protocol
provides a way for doing so. In the case of HTTP, the locale is
communicated via the
| |
| setLongContentLength | back to summary |
|---|---|
| public void setLongContentLength(long len) | |
| setStatus | back to summary |
|---|---|
| public void setStatus(int sc) Implements javax. Doc from javax. Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the SC_OK or SC_MOVED_TEMPORARILY status codes). If this method is used to set an error code, then the container's
error page mechanism will not be triggered. If there is an error and
the caller wishes to invoke an error page defined in the web
application, then This method preserves any cookies and other response headers. Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container specific.
| |
| setStatus | back to summary |
|---|---|
| public void setStatus(int sc, String sm) Implements javax.
| |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Doc from java. Returns a string representation of the object.
| |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| public void | print(String
the s)String to send to the clientOverrides javax. String to the client,
without a carriage return-line feed (CRLF)
character at the end.
|
| public void | println(String
the s)String to write to the clientOverrides javax. String to the client,
followed by a carriage return-line feed (CRLF).
|
| public void | write(int
the b)byte.Implements abstract java. |
| public void | write(byte[]
the data. b, int the start offset in the data. off, int the number of bytes to write. len)Overrides java. len bytes from the specified byte array
starting at offset off to this output stream.
|
| NullOutput | back to summary |
|---|---|
| private NullOutput() | |
| back to summary | |
|---|---|
| public void print(String s) throws IOException Overrides javax. Doc from javax. Writes a
| |
| println | back to summary |
|---|---|
| public void println(String s) throws IOException Overrides javax. Doc from javax. Writes a
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements abstract java. Doc from java. Writes the specified byte to this output stream. The general
contract for
| |
| write | back to summary |
|---|---|
| public void write(byte[] b, int off, int len) throws IOException Overrides java. Doc from java. Writes
If
If
| |