ServletResponse object and
passes it as an argument to the servlet's service method.
To send binary data in a MIME body response, use
the returned by ServletOutputStream.
To send character data, use the getOutputStream()PrintWriter object
returned by . To mix binary and text data,
for example, to create a multipart response, use a
getWriter()ServletOutputStream and manage the character sections
manually.
The charset for the MIME body response can be specified with
. For example, "text/html; charset=Shift_JIS".
The charset can alternately be set using setContentType(java.lang.String).
If no charset is specified, ISO-8859-1 will be used.
The setLocale(java.util.Locale)setContentType or setLocale method
must be called before getWriter for the charset to
affect the construction of the writer.
See the Internet RFCs such as RFC 2045 for more information on MIME. Protocols such as SMTP and HTTP define profiles of MIME, and those standards are still evolving.
ServletOutputStreamIf no charset has been assigned, it is implicitly
set to ISO-8859-1 (Latin-1).
See RFC 2047 (http://ds.internic.net/rfc/rfc2045.txt) for more information about character encoding and MIME.
String specifying the
name of the charset, for
example, ISO-8859-1ServletOutputStream suitable for writing binary
data in the response. The servlet container does not encode the
binary data. Either this method or getWriter() may
be called to write the body, not both.
ServletOutputStream for writing binary datajava.lang.IllegalStateException if the getWriter method
has been called on this responsejava.io.IOException if an input or output exception occurredgetWriter()PrintWriter object that
can send character text to the client.
The character encoding used is the one specified
in the charset= property of the
setContentType(java.lang.String) method, which must be called
before calling this method for the charset to take effect.
If necessary, the MIME type of the response is modified to reflect the character encoding used.
Either this method or may be called
to write the body, not both.
getOutputStream()
PrintWriter object that
can return character data to the clientjava.io.UnsupportedEncodingException if the charset specified in
setContentType cannot be
usedjava.lang.IllegalStateException if the getOutputStream
method has already been called for this
response objectjava.io.IOException if an input or output exception occurredgetOutputStream()setContentType(java.lang.String)text/html; charset=ISO-8859-4.
If obtaining a PrintWriter, this method should be
called first.
type a String specifying the MIME
type of the contentgetOutputStream()getWriter()getBufferSize.
A larger buffer allows more content to be written before anything is actually sent, thus providing the servlet with more time to set appropriate status codes and headers. A smaller buffer decreases server memory load and allows the client to start receiving data more quickly.
This method must be called before any response body content is
written; if content has been written, this method throws an
IllegalStateException.
size the preferred buffer sizejava.lang.IllegalStateException if this method is called after
content has been writtengetBufferSize()flushBuffer()isCommitted()reset()setBufferSize(int)flushBuffer()isCommitted()reset()setBufferSize(int)getBufferSize()flushBuffer()reset()IllegalStateException.
java.lang.IllegalStateException if the response has already been
committedsetBufferSize(int)getBufferSize()flushBuffer()isCommitted()getWriter(). By default, the response locale
is the default locale for the server.
loc the locale of the responsegetLocale()