ServletResponse Interface

public interface ServletResponse
This interface specifies an object to assist a servlet in sending a response to the client. The web container creates an instance of this object while calling the service() method of the GenericServlet or the HttpServlet.
Method of ServletResponse Interface
  1. public void flushBuffer()
              This method forces any content in the buffer to be written to the client.
  2. public   int getBufferSize()
              This method returns the actual buffer size used for the response.
  3. public  void setContentType(String type)
              This method sets the content type of the response being sent to the client, if the response has not been committed yet.
  4. public   String getCharacterEncoding()
             This method returns the name of the character encoding (MIME charset) used for the body sent in this response.
  5. public  String getContentType()
              This method returns the content type used for the MIME body sent in this response.
  6. public  Locale getLocale()
              This method returns the locale specified for this response using the setLocale(Locale) method.  
  7. public ServletOutputStream getOutputStream()
             This method returns a ServletOutputStream suitable for writing binary data in the response.
  8. public  PrintWriter getWriter()
              This method returns a PrintWriter object that can send character text to the client.
  9. public   boolean isCommitted()
              This method returns a boolean indicating if the response has been committed.
  10. public   void reset()
              This method clears any data that exists in the buffer as well as the status code and headers.
  11. public  void resetBuffer()
              This method clears the content of the underlying buffer in the response without clearing headers or status code.
  12. public  void setBufferSize(int size)
              This method sets the preferred buffer size for the body of the response.
  13. public  void setCharacterEncoding(String charset)
              This method sets the character encoding (MIME charset) of the response being sent to the client, for example, to UTF-8.
  14. public  void setContentLength(int len)
              This method sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header.
  15. public  void setLocale(Locale loc)
              This method sets the locale of the response, if the response has not been committed yet.


Latest Tutorial

Most Visited Tutorial