HttpServletResponse is a predefined interface present in javax.servlet.http package. It can be said that it is a mirror image of request object. The response object is where the servlet can write information about the data it will send back. Whereas the majority of the methods in the request object start with GET, indicating that they get a value, many of the important methods in the response object start with SET, indicating that they change some property. Note that these interfaces adhere to the usual naming conventions for beans.
Methods in HttpServletResponse
i. public void addCookie(Cookie cookie)
Adds the specified cookie to the response. This method can be called multiple times to set more than one cookie.
ii. public void addDateHeader (String name, long date)
Adds a response header with the given name and date-value.
iii. public void addHeader(String name,String value)
Adds a response header with the given name and value.
iv public void addlntHeader(String name,int value)
Adds a response header with the given name and integer value.
v public boolean containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set.
vi. 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.
vii. 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.
viii. public void sendError(int sc) throws IOException
Sends an error response to the client using the specified status code and clearing the buffer.
ix. public void sendError(int Be, String mag) throws IOException
Sends an error response to the client using the specified status clearing the buffer.
x. public void sendRedirect(string location) throws IOException
Sends a temporary redirect response to the client using the specified redirect location URL.
xi. public void setDateHeader(String name,long date)
Sets a response header with the given name and date-value.
xii. public void setHeader(String name, String value)
Sets a response header with the given name and value.
xiii. public void setlntHeader (String name,int value)
Sets a response header with the given name and integer value.
xiv public void setStatus(int sc)
Sets the status code for this response.