|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
ServletReponse control the output to the client.
A typical servlet will output its response as follows:
response.setContentType("text/html; charset=UTF-8");
PrintWriter pw = response.getWriter();
pw.println("Hello, world");
setContentType
or setLocale
to
set the character encoding.
response.setContentType("text/html; charset=ISO-8859-2");
Method Summary | |
void |
flushBuffer()
Flushes the buffer to the client. |
int |
getBufferSize()
Returns the size of the output buffer. |
java.lang.String |
getCharacterEncoding()
Returns the character encoding the response is using for output. |
java.util.Locale |
getLocale()
Returns the output locale. |
ServletOutputStream |
getOutputStream()
Returns an output stream for writing to the client. |
java.io.PrintWriter |
getWriter()
Returns a PrintWriter with the proper character encoding for writing text data to the client. |
boolean |
isCommitted()
Returns true if some data has actually been send to the client. |
void |
reset()
Resets the output stream, clearing headers and the output buffer. |
void |
setBufferSize(int size)
Sets the output buffer size to size . |
void |
setContentLength(int len)
Deprecated. |
void |
setContentType(java.lang.String type)
Sets the response content type. |
void |
setLocale(java.util.Locale locale)
Sets the output locale. |
Method Detail |
public void setContentType(java.lang.String type)
getWriter()
so the writer can use the
proper character encoding.
To set the output character encoding to ISO-8859-2, use the
following:
response.setContentType("text/html; charset=ISO-8859-2");
type
- the mime type of the outputpublic java.lang.String getCharacterEncoding()
public void setLocale(java.util.Locale locale)
public java.util.Locale getLocale()
public ServletOutputStream getOutputStream() throws java.io.IOException
public java.io.PrintWriter getWriter() throws java.io.IOException
public void setBufferSize(int size)
size
. The servlet engine
may round the size up.size
- the new output buffer size.public int getBufferSize()
public void flushBuffer() throws java.io.IOException
public boolean isCommitted()
public void reset()
reset()
after data has been committed is illegal.isCommitted()
is true.public void setContentLength(int len)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |