| net.jforum.context.ResponseContext
All known Subclasses: net.jforum.context.web.WebResponseContext,
ResponseContext | public interface ResponseContext (Code) | | User: SergeMaslyukov Date: 20.08.2006 Time: 18:48:56 $Id: WebContextResponse.java,v 1.1
2006/08/20 15:30:30 sergemaslyukov Exp $
|
Method Summary | |
public void | addCookie(Cookie cookie) Adds the specified cookie to the response. | public void | addHeader(String name, String value) Adds a response header with the given name and value. | public boolean | containsHeader(String name) Returns a boolean indicating whether the named response header has already been set. | 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) Encodes the specified URL by including the session ID in it, or, if encoding is not needed,
returns the URL unchanged. | public String | getCharacterEncoding() Returns the name of the character encoding (MIME charset) used for the body sent in this
response. | public ServletOutputStream | getOutputStream() Returns a
javax.servlet.ServletOutputStream suitable for writing binary data in the
response. | public PrintWriter | getWriter() Returns a PrintWriter object that can send character text to the client. | public void | sendError(int sc) Sends an error response to the client using the specified status code and clearing the
buffer. | public void | sendRedirect(String location) Sends a temporary redirect response to the client using the specified redirect location URL.
This method can accept relative URLs; the servlet container must convert the relative URL to
an absolute URL before sending the response to the client. | public void | setContentLength(int len) Sets the length of the content body in the response In HTTP servlets, this method sets the
HTTP Content-Length header. | public void | setContentType(String type) Sets the content type of the response being sent to the client, if the response has not been
committed yet. | public void | setHeader(String name, String value) Sets a response header with the given name and value. |
addCookie | public void addCookie(Cookie cookie)(Code) | | Adds the specified cookie to the response. This method can be called multiple times to set
more than one cookie.
Parameters: cookie - the Cookie to return to the client |
addHeader | public void addHeader(String name, String value)(Code) | | Adds a response header with the given name and value. This method allows response headers to
have multiple values.
Parameters: name - the name of the header Parameters: value - the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) |
containsHeader | public boolean containsHeader(String name)(Code) | | Returns a boolean indicating whether the named response header has already been set.
Parameters: name - the header name true if the named response header has already been set;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 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 separated 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.
Parameters: url - the url to be encoded. the encoded URL if encoding is needed; the unchanged URL otherwise. See Also: ResponseContext.sendRedirect See Also: ResponseContext.encodeUrl |
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 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.
Parameters: url - the url to be encoded. the encoded URL if encoding is needed; the unchanged URL otherwise. |
getCharacterEncoding | public String getCharacterEncoding()(Code) | | Returns the name of the character encoding (MIME charset) used for the body sent in this
response. The character encoding may have been specified explicitly using the
ResponseContext.setCharacterEncoding or
ResponseContext.setContentType methods, or implicitly using the
ResponseContext.setLocale method. Explicit specifications take precedence over implicit
specifications. Calls made to these methods after getWriter has been called or
after the response has been committed have no effect on the character encoding. If no
character encoding has been specified, ISO-8859-1 is returned.
See RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) for more information about character
encoding and MIME.
a String specifying the name of the character encoding, for example,UTF-8 |
sendError | public void sendError(int sc) throws IOException(Code) | | Sends an error response to the client using the specified status code and clearing the
buffer.
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.
Parameters: sc - the error status code exception: java.io.IOException - If an input or output exception occurs exception: IllegalStateException - If the response was committed before this method call |
sendRedirect | public void sendRedirect(String location) throws IOException(Code) | | Sends a temporary redirect response to the client using the specified redirect location URL.
This method can accept relative URLs; the servlet container must convert the relative URL to
an absolute URL before sending the response to the client. If the location is relative
without a leading '/' the container interprets it as relative to the current request URI. If
the location is relative with a leading '/' the container interprets it as relative to the
servlet container root.
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.
Parameters: location - the redirect location URL exception: IOException - If an input or output exception occurs exception: IllegalStateException - If the response was committed or if a partial URL is given and cannot be converted into a valid URL |
setContentLength | public void setContentLength(int len)(Code) | | Sets the length of the content body in the response In HTTP servlets, this method sets the
HTTP Content-Length header.
Parameters: len - an integer specifying the length of the content being returned to the client; sets the Content-Length header |
setContentType | public void setContentType(String type)(Code) | | 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, text/html;charset=UTF-8 . The response's character encoding is only
set from the given content type if this method is called before getWriter is
called.
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 getWriter has been called
or after the response has been committed.
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 Content-Type header is used.
Parameters: type - a String specifying the MIME type of the content See Also: ResponseContext.setLocale See Also: ResponseContext.setCharacterEncoding See Also: ResponseContext.getOutputStream See Also: ResponseContext.getWriter |
setHeader | public void setHeader(String name, String value)(Code) | | 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 containsHeader method can be used
to test for the presence of a header before setting its value.
Parameters: name - the name of the header Parameters: value - the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt) See Also: ResponseContext.containsHeader See Also: ResponseContext.addHeader |
|
|