Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |
To write MIME bodies which consist of binary data, use the
output stream returned by getOutputStream
. To
write MIME bodies consisting of text data, use the writer returned
by getWriter
. If you need to mix binary and
text data, for example because you're creating a multipart response,
use the output stream to write the multipart headers, and use that
to build your own text bodies.
If you don't explicitly set the character set in your MIME media
type, with setContentType
, one will be
selected and the content type will be modified accordingly. If you
will be using a writer, and want to call the
setContentType
method, you must do so before calling
the getWriter
method. If you will be using the output
stream, and want to call setContentType
, you must do so
before using the output stream to write the MIME body.
For more information about MIME, see the Internet RFCs such as RFC 2045, the first in a series which defines MIME. Note that protocols such SMTP and HTTP define application-specific profiles of MIME, and that standards in this area are evolving.
Method Summary | |
String | getCharacterEncoding()
|
ServletOutputStream | getOutputStream()
|
PrintWriter | getWriter()
|
void | setContentLength(int len)
|
void | setContentType(String type)
|
Method Detail |
public void setContentLength(int len)
len
- the content length
public void setContentType(String type)
This response property may only be assigned one time. If a
writer is to be used to write a text response, this method must
be called before the method getWriter
. If an
output stream will be used to write a response, this method must
be called before the output stream is used to write response
data.
type
- the content's MIME type
public ServletOutputStream getOutputStream() throws IOException
public PrintWriter getWriter() throws IOException
public String getCharacterEncoding()
Contents | Package | Class | Tree | Deprecated | Index | Help | Java 1.2 Beta 3 | ||
PREV | NEXT | SHOW LISTS | HIDE LISTS |