Wednesday, March 30, 2011

Java HttpServletResponse

HttpServletResponse is an interface from package javax.servlet.http. It extends javax.servlet.ServletResponse.

The important interface members are:
* addCookie(Cookie cookie);
* addHeader(String name, String value);
* sendError(int sc) Sends an error response to the client using the specified status code and clearing the buffer;
* sendError(int sc, String msg) Sends an error response to the client using the specified status.
* sendRedirect( String newLocation ) throws IOException - Sends a temporary redirect response to the client using the specified redirect location URL. Realised by http code 302 (Redirect).
* setHeader(String name, String value);
* setStatus(int sc) Sets the status code for this response.

Noticable methods from the super interface javax.servlet.ServletResponse:
* String getCharacterEncoding();
* String getContentType() - Returns the content type used for the MIME body;
* boolean isCommitted();
* setCharacterEncoding(String charset);
* setContentType(String type);

No comments:

Post a Comment