|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
public interface ServletResponse
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 |
disable()
Disables the response |
void |
enable()
Enables the response |
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.lang.String |
getContentType()
Returns the content type for the response. |
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. |
boolean |
isDisabled()
Returns true if the response is disabled |
void |
reset()
Resets the output stream, clearing headers and the output buffer. |
void |
resetBuffer()
Resets the output stream, clearing headers and the output buffer. |
void |
setBufferSize(int size)
Sets the output buffer size to size. |
void |
setCharacterEncoding(java.lang.String charset)
Sets the character encoding the response is using for output. |
void |
setContentLength(int len)
Explicitly sets the length of the result value. |
void |
setContentType(java.lang.String type)
Sets the response content type. |
void |
setLocale(java.util.Locale locale)
Sets the output locale. |
| Method Detail |
|---|
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 outputjava.lang.String getContentType()
java.lang.String getCharacterEncoding()
void setCharacterEncoding(java.lang.String charset)
void setLocale(java.util.Locale locale)
java.util.Locale getLocale()
ServletOutputStream getOutputStream()
throws java.io.IOException
java.io.IOException
java.io.PrintWriter getWriter()
throws java.io.IOException
java.io.IOExceptionvoid setBufferSize(int size)
size. The servlet engine
may round the size up.
size - the new output buffer size.int getBufferSize()
void flushBuffer()
throws java.io.IOException
java.io.IOExceptionboolean isCommitted()
void reset()
reset() after data has been committed is illegal.
java.lang.IllegalStateException - if isCommitted() is true.void resetBuffer()
reset() after data has been committed is illegal.
java.lang.IllegalStateException - if isCommitted() is true.void setContentLength(int len)
void disable()
void enable()
boolean isDisabled()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||