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
-
getCharacterEncoding()
- Returns the characterset encoding in use by this Response
-
getOutputStream()
- Creates a ServletOutputStream for the servlet to write the data to.
-
getWriter()
- Creates a PrintWriter for the servlet to print text to.
-
setContentLength(int)
- Tells the client how many bytes to expect.
-
setContentType(String)
- Tells the client what mime type to expect
setContentLength
public abstract void setContentLength(int length)
- Tells the client how many bytes to expect.
- Parameters:
- length - the number of bytes in the reply
setContentType
public abstract void setContentType(String type)
- Tells the client what mime type to expect
- Parameters:
- type - the mime type of the content
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
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
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