All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface javax.servlet.ServletResponse

public interface ServletResponse
A servlet can use this class to pass information to the client.

Version:
Servlet API 2.0

Method Index

 o getCharacterEncoding()
Returns the characterset encoding in use by this Response
 o getOutputStream()
Creates a ServletOutputStream for the servlet to write the data to.
 o getWriter()
Creates a PrintWriter for the servlet to print text to.
 o setContentLength(int)
Tells the client how many bytes to expect.
 o setContentType(String)
Tells the client what mime type to expect

Methods

 o setContentLength
 public abstract void setContentLength(int length)
Tells the client how many bytes to expect.

Parameters:
length - the number of bytes in the reply
 o setContentType
 public abstract void setContentType(String type)
Tells the client what mime type to expect

Parameters:
type - the mime type of the content
 o getOutputStream
 public abstract ServletOutputStream getOutputStream() throws IOException
Creates a ServletOutputStream for the servlet to write the data to. setContentLength and setContentType can only be called before anything is written to this stream. It is only possible to call getWriter or getOutputStream on a response, but not both.

Returns:
ServletOutputStream to write binary data
Throws: IOException
if a i/o exception occurs
Throws: IllegalStateException
if getWriter was already called on this response
 o getWriter
 public abstract PrintWriter getWriter() throws IOException
Creates a PrintWriter for the servlet to print text to. The contenttype must be set before calling this method. It is only possible to call getWriter or getOutputStream on a response, but not both.

Returns:
the created PrintWriter
Throws: IOException
if a i/o exception occurs
Throws: IllegalStateException
if getOutputStream was already called on this response
Throws: UnsupportedEncodingException
if no suitable character encoding can be used
 o getCharacterEncoding
 public abstract String getCharacterEncoding()
Returns the characterset encoding in use by this Response

Returns:
the characterset encoding

All Packages  Class Hierarchy  This Package  Previous  Next  Index