| java.lang.Object com.quadcap.http.server22.HttpResponse
HttpResponse | public class HttpResponse implements HttpServletResponse(Code) | | An HTTP servlet response. This interface allows a servlet's
service method to manipulate HTTP-protocol specified
header information and return data to its client. It is implemented
by network service developers for use within servlets.
author: Stan Bailes |
Constructor Summary | |
public | HttpResponse(WebWorker w) Construct a new HttpResponse for the specified worker. |
Method Summary | |
public void | addCookie(Cookie cookie) Adds the specified cookie to the response. | public void | addDateHeader(String name, long date) | public void | addHeader(String name, String value) Add a new header value -- this method allows multiple headers with
the same name. | public void | addIntHeader(String name, int value) | final void | appendHeader(String name, String value) | public boolean | containsHeader(String name) Checks whether the response message header has a field with
the specified name. | public String | encodeRedirectURL(String url) | public String | encodeRedirectUrl(String url) Encodes the specified URL for use in the
sendRedirect method or, if encoding is not needed,
returns the URL unchanged. | public String | encodeURL(String url) | public String | encodeUrl(String url) Encodes the specified URL by including the session ID in it,
or, if encoding is not needed, returns the URL unchanged.
The implementation of this method should include 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.
All URLs emitted by a Servlet should be run through this
method. | void | flush() | public void | flushBuffer() | public int | getBufferSize() | public String | getCharacterEncoding() Returns the character set encoding used for this MIME body. | int | getContentLength() | public JspWriter | getJspWriter(int bufferSize, boolean autoFlush) | public Locale | getLocale() | public ServletOutputStream | getOutputStream() Returns an output stream for writing binary response data. | public PrintWriter | getWriter() Returns a print writer for writing formatted text responses. | public boolean | isCommitted() | final void | maybeSetContentLength(int len) | public void | reset(HttpOutputStream os) | public void | reset() | public void | sendError(int scode, String msg) Sends an error response to the client using the specified status
code and descriptive message. | public void | sendError(int scode) Sends an error response to the client using the specified
status code and a default message. | public void | sendRedirect(String location) Sends a temporary redirect response to the client using the
specified redirect location URL. | public void | setBufferSize(int size) | public void | setContentLength(int len) Sets the content length for this response. | public void | setContentType(String type) Sets the content type for this response. | public void | setDateHeader(String name, long date) Adds a field to the response header with the given name and
date-valued field. | final void | setFixedHeader(String name, String val) | public void | setHeader(String name, String value) Adds a field to the response header with the given name and value.
If the field had already been set, the new value overwrites the
previous one. | public void | setIntHeader(String name, int value) Adds a field to the response header with the given name and
integer value. | void | setKeepAlive(boolean v) | public void | setLocale(Locale locale) | void | setProtocol(String p) | public void | setStatus(int sc, String sm) Sets the status code and message for this response. | public void | setStatus(int sc) Sets the status code for this response. | final static void | write(OutputStream out, String s) | void | writeAttr(WorkerOutputStream out, String name, String val) | void | writeCookies(WorkerOutputStream out) | final void | writeDateHeader(WorkerOutputStream out) | final void | writeHeader(WorkerOutputStream out, String name, String val) | public void | writeHeaders() |
CONNECTION_CLOSE | final static byte[] CONNECTION_CLOSE(Code) | | |
CONNECTION_KEEPALIVE | final static byte[] CONNECTION_KEEPALIVE(Code) | | |
CONTENT_LENGTH | final static byte[] CONTENT_LENGTH(Code) | | |
CONTENT_TYPE | final static byte[] CONTENT_TYPE(Code) | | |
CRLF | final static byte[] CRLF(Code) | | |
DEFAULT_CONTENT_TYPE | final static byte[] DEFAULT_CONTENT_TYPE(Code) | | |
GMTString | static byte[] GMTString(Code) | | |
OKRESPONSE | final static byte[] OKRESPONSE(Code) | | |
anyHeaders | boolean anyHeaders(Code) | | |
changedCode | boolean changedCode(Code) | | |
contentLength | int contentLength(Code) | | |
digits | static byte[] digits(Code) | | |
fixedHeaders | byte[] fixedHeaders(Code) | | |
getOutputStreamCalled | public boolean getOutputStreamCalled(Code) | | |
getWriterCalled | public boolean getWriterCalled(Code) | | |
headerBufValid | boolean headerBufValid(Code) | | |
headerSep | final static byte[] headerSep(Code) | | |
jWriterInit | boolean jWriterInit(Code) | | |
keepAlive | boolean keepAlive(Code) | | |
HttpResponse | public HttpResponse(WebWorker w)(Code) | | Construct a new HttpResponse for the specified worker.
Parameters: w - the worker handling this http request |
addCookie | public void addCookie(Cookie cookie)(Code) | | Adds the specified cookie to the response. It can be called
multiple times to set more than one cookie.
Parameters: cookie - the Cookie to return to the client |
addDateHeader | public void addDateHeader(String name, long date)(Code) | | |
addHeader | public void addHeader(String name, String value)(Code) | | Add a new header value -- this method allows multiple headers with
the same name.
|
addIntHeader | public void addIntHeader(String name, int value)(Code) | | |
containsHeader | public boolean containsHeader(String name)(Code) | | Checks whether the response message header has a field with
the specified name.
Parameters: name - the header field name true if the response message header has a field withthe specified name; false otherwise |
encodeRedirectUrl | public String encodeRedirectUrl(String url)(Code) | | Encodes the specified URL for use in the
sendRedirect method or, if encoding is not needed,
returns the URL unchanged. The implementation of this method
should include the logic to determine whether the session ID
needs to be encoded in the URL. Because the rules for making
this determination 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 canont be used with browsers which do not support
cookies.
Parameters: url - the url to be encoded. the encoded URL if encoding is needed; the unchanged URLotherwise. |
encodeUrl | public String encodeUrl(String url)(Code) | | Encodes the specified URL by including the session ID in it,
or, if encoding is not needed, returns the URL unchanged.
The implementation of this method should include 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.
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.
Parameters: url - the url to be encoded. the encoded URL if encoding is needed; the unchanged URLotherwise. |
getBufferSize | public int getBufferSize()(Code) | | |
getCharacterEncoding | public String getCharacterEncoding()(Code) | | Returns the character set encoding used for this MIME body.
The character encoding is either the one specified in the
assigned content type, or one which the client understands.
If no content type has yet been assigned, it is implicitly
set to text/plain
|
getContentLength | int getContentLength()(Code) | | |
getWriter | public PrintWriter getWriter() throws IOException(Code) | | Returns a print writer for writing formatted text responses. The
MIME type of the response will be modified, if necessary, to reflect
the character encoding used, through the charset=...
property. This means that the content type must be set before
calling this method.
exception: UnsupportedEncodingException - if no such encoding canbe provided exception: IllegalStateException - if getOutputStream has beencalled on this same request. exception: IOException - on other errors. |
isCommitted | public boolean isCommitted()(Code) | | |
maybeSetContentLength | final void maybeSetContentLength(int len)(Code) | | |
sendError | public void sendError(int scode, String msg) throws IOException(Code) | | Sends an error response to the client using the specified status
code and descriptive message. If setStatus has previously been
called, it is reset to the error status code. The message is
sent as the body of an HTML page, which is returned to the user
to describe the problem. The page is sent with a default HTML
header; the message is enclosed in simple body tags
(<body></body>).
Parameters: sc - the status code Parameters: msg - the detail message exception: IOException - If an I/O error has occurred. |
sendError | public void sendError(int scode) throws IOException(Code) | | Sends an error response to the client using the specified
status code and a default message.
Parameters: scode - the status code exception: IOException - If an I/O error has occurred. |
sendRedirect | public void sendRedirect(String location) throws IOException(Code) | | Sends a temporary redirect response to the client using the
specified redirect location URL. The URL must be absolute (for
example, https://hostname/path/file.html ).
Relative URLs are not permitted here.
Parameters: location - the redirect location URL exception: IOException - If an I/O error has occurred. |
setContentLength | public void setContentLength(int len)(Code) | | Sets the content length for this response.
Parameters: len - the content length |
setContentType | public void setContentType(String type)(Code) | | Sets the content type for this response. This type may later
be implicitly modified by addition of properties such as the MIME
charset=<value> if the service finds it necessary,
and the appropriate media type property has not been set.
This response property may only be assigned one time. If a
writer is to be used to write a text response, this method must
be called before the method getWriter . If an
output stream will be used to write a response, this method must
be called before the output stream is used to write response
data.
Parameters: type - the content's MIME type |
setDateHeader | public void setDateHeader(String name, long date)(Code) | | Adds a field to the response header with the given name and
date-valued field. The date is specified in terms of
milliseconds since the epoch. If the date field had already
been set, the new value overwrites the previous one. The
containsHeader method can be used to test for the
presence of a header before setting its value.
Parameters: name - the name of the header field Parameters: value - the header field's date value |
setHeader | public void setHeader(String name, String value)(Code) | | Adds a field to the response header with the given name and value.
If the field had already been set, the new value overwrites the
previous one. The containsHeader method can be
used to test for the presence of a header before setting its
value.
Parameters: name - the name of the header field Parameters: value - the header field's value |
setIntHeader | public void setIntHeader(String name, int value)(Code) | | Adds a field to the response header with the given name and
integer value. If the field had already been set, the new value
overwrites the previous one. The containsHeader
method can be used to test for the presence of a header before
setting its value.
Parameters: name - the name of the header field Parameters: value - the header field's integer value |
setKeepAlive | void setKeepAlive(boolean v)(Code) | | |
setStatus | public void setStatus(int sc, String sm)(Code) | | Sets the status code and message for this response. If the
field had already been set, the new value overwrites the
previous one. The message is sent as the body of an HTML
page, which is returned to the user to describe the problem.
The page is sent with a default HTML header; the message
is enclosed in simple body tags (<body></body>).
Parameters: sc - the status code Parameters: sm - the status message |
setStatus | public void setStatus(int sc)(Code) | | 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 status codes SC_OK or SC_MOVED_TEMPORARILY). If there
is an error, the sendError method should be used
instead.
Parameters: sc - the status code |
writeHeaders | public void writeHeaders() throws IOException(Code) | | Write the result code and the message headers for the response
|
|
|