Interface RebelHttpServletResponse
Separate interface is required as the javax.servlet.http.HttpServletResponse
interface is not loaded by the boot class loader.
In practice a bytecode processor makes javax.servlet.http.HttpServletResponse
to extend the given interface.
-
Method Summary
Modifier and TypeMethodDescriptionencodeRedirectURL(String url) Encodes the specified URL for use in thesendRedirectmethod or, if encoding is not needed, returns the URL unchanged.Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.A access mirror for HttpServletResponse's methodvoidsendError(int sc) Sends an error response to the client using the specified status code and clearing the buffer.voidSends an error response to the client using the specified status.voidsendRedirect(String location) Sends a temporary redirect response to the client using the specified redirect location URL.voidA access mirror for HttpServletResponse's methodvoidsetStatus(int sc) A access mirror for HttpServletResponse's method
-
Method Details
-
encodeURL
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.- Returns:
- the encoded URL if encoding is needed; the unchanged URL otherwise.
-
encodeRedirectURL
Encodes the specified URL for use in thesendRedirectmethod 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 theencodeURLmethod.All URLs sent to the
HttpServletResponse.sendRedirectmethod 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.- Returns:
- the encoded URL if encoding is needed; the unchanged URL otherwise.
- See Also:
-
sendError
Sends an error response to the client using the specified status. 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", leaving cookies and other headers unmodified. 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.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 codemsg- the descriptive message- Throws:
IOException- If an input or output exception occursIllegalStateException- If the response was committed
-
sendError
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- Throws:
IOException- If an input or output exception occursIllegalStateException- If the response was committed before this method call
-
sendRedirect
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- Throws:
IOException- If an input or output exception occursIllegalStateException- If the response was committed or if a partial URL is given and cannot be converted into a valid URL
-
setStatus
void setStatus(int sc) A access mirror for HttpServletResponse's method -
setHeader
A access mirror for HttpServletResponse's method -
getWriter
A access mirror for HttpServletResponse's method- Throws:
IOException
-