HttpServletResponse Interface

public interface HttpServletResponse extends ServletResponse
The web container provides an object that implements this interface and passes it into the servlet through the service()method.The servlet can modify response headers and return result throgh the HttpServletResponse interface object.
Method of HttpServletResponse Interface
  1. public  void addCookie(Cookie cookie)
              This method adds the specified cookie to the response.
  2. public  void addDateHeader(String name, long date)
              This method adds a response header with the given name and date-value.
  3. public  void addHeader(String name, String value)
              This method adds a response header with the given name and value.  
  4. public void addIntHeader(String name, int value)
              This method adds a response header with the given name and integer value.
  5. public   boolean containsHeader(String name)
              This method returns a boolean indicating whether the named response header has already been set.
  6. public  String encodeRedirectUrl(String url)
              Deprecated. As of version 2.1, use encodeRedirectURL(String url) instead
  7. public  String encodeRedirectURL(String url)
              This method encodes the specified URL for use in the sendRedirect method or, if encoding is not needed, returns the URL unchanged.
  8. public   String encodeUrl(String url)
              Deprecated. As of version 2.1, use encodeURL(String url) instead  
  9. public String encodeURL(String url)
              This method encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged.
  10. public  void sendError(int sc)
               This method sends an error response to the client using the specified status code and clearing the buffer.  
  11. public void sendError(int sc, String msg)
              This method sends an error response to the client using the specified status clearing the buffer.
  12. public  void sendRedirect(String location)
              This method sends a temporary redirect response to the client using the specified redirect location URL.  
  13. public void setDateHeader(String name, long date)
              This method sets a response header with the given name and date-value.
  14. public  void setHeader(String name, String value)
              This method sets a response header with the given name and value.
  15. public  void setIntHeader(String name, int value)
             This method sets a response header with the given name and integer value.
  16. public  void setStatus(int sc)
              This method sets the status code for this response.
  17. public  void setStatus(int sc, String sm)
              Deprecated. As of version 2.1, due to ambiguous meaning of the message parameter. To set a status code use setStatus(int), to send an error with a description use sendError(int, String). Sets the status code and message for this response.
 



 

Latest Tutorial


Most Visited Tutorial