|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--javax.servlet.http.NoBodyResponse
Constructor Summary | |
(package private) |
NoBodyResponse(HttpServletResponse r)
|
Method Summary | |
void |
addCookie(Cookie cookie)
Adds the specified cookie to the response. |
void |
addDateHeader(String name,
long value)
Adds a response header with the given name and date-value. |
void |
addHeader(String name,
String value)
Adds a response header with the given name and value. |
void |
addIntHeader(String name,
int value)
Adds a response header with the given name and integer value. |
boolean |
containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set. |
String |
encodeRedirectUrl(String url)
Deprecated. As of Version 2.1, replaced by HttpServletResponse.encodeRedirectURL(java.lang.String) . |
String |
encodeRedirectURL(String url)
Encodes the specified URL for use in the sendRedirect method or, if encoding is not needed,
returns the URL unchanged. |
String |
encodeUrl(String url)
Deprecated. As of Version 2.1, replaced by HttpServletResponse.encodeURL(java.lang.String) . |
String |
encodeURL(String url)
Encodes the specified URL by including the session ID in it, or, if encoding is not needed, returns the URL unchanged. |
void |
flushBuffer()
Forces any content in the buffer to be written to the client. |
int |
getBufferSize()
Returns the actual buffer size used for the response. |
String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response. |
Locale |
getLocale()
Returns the locale assigned to the response. |
ServletOutputStream |
getOutputStream()
Returns a ServletOutputStream suitable for writing binary
data in the response. |
PrintWriter |
getWriter()
Returns a PrintWriter object that
can send character text to the client. |
boolean |
isCommitted()
Returns a boolean indicating if the response has been committed. |
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
sendError(int sc)
Sends an error response to the client using the specified status. |
void |
sendError(int sc,
String msg)
Sends an error response to the client using the specified status code and descriptive message. |
void |
sendRedirect(String location)
Sends a temporary redirect response to the client using the specified redirect location URL. |
void |
setBufferSize(int size)
Sets the preferred buffer size for the body of the response. |
(package private) void |
setContentLength()
|
void |
setContentLength(int len)
Sets the length of the content body in the response In HTTP servlets, this method sets the HTTP Content-Length header. |
void |
setContentType(String type)
Sets the content type of the response being sent to the client. |
void |
setDateHeader(String name,
long date)
Sets a response header with the given name and date-value. |
void |
setHeader(String name,
String value)
Sets a response header with the given name and value. |
void |
setIntHeader(String name,
int value)
Sets a response header with the given name and integer value. |
void |
setLocale(Locale loc)
Sets the locale of the response, setting the headers (including the Content-Type's charset) as appropriate. |
void |
setStatus(int sc)
Sets the status code for this response. |
void |
setStatus(int sc,
String sm)
Deprecated. |
Methods inherited from class java.lang.Object |
|
Constructor Detail |
NoBodyResponse(HttpServletResponse r)
Method Detail |
void setContentLength()
public void setContentLength(int len)
ServletResponse
setContentLength
in interface ServletResponse
javax.servlet.ServletResponse
len
- an integer specifying the length of the
content being returned to the client; sets
the Content-Length headerpublic void setContentType(String type)
ServletResponse
text/html; charset=ISO-8859-4
.
If obtaining a PrintWriter
, this method should be
called first.
setContentType
in interface ServletResponse
javax.servlet.ServletResponse
type
- a String
specifying the MIME
type of the contentServletResponse.getOutputStream()
,
ServletResponse.getWriter()
public ServletOutputStream getOutputStream() throws IOException
ServletResponse
ServletOutputStream
suitable for writing binary
data in the response. The servlet container does not encode the
binary data. Either this method or ServletResponse.getWriter()
may
be called to write the body, not both.getOutputStream
in interface ServletResponse
javax.servlet.ServletResponse
ServletOutputStream
for writing binary dataIllegalStateException
- if the getWriter
method
has been called on this responseIOException
- if an input or output exception occurredServletResponse.getWriter()
public String getCharacterEncoding()
ServletResponse
If 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.
getCharacterEncoding
in interface ServletResponse
javax.servlet.ServletResponse
String
specifying the
name of the charset, for
example, ISO-8859-1
public PrintWriter getWriter() throws UnsupportedEncodingException
ServletResponse
PrintWriter
object that
can send character text to the client.
The character encoding used is the one specified
in the charset=
property of the
ServletResponse.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 ServletResponse.getOutputStream()
may be called
to write the body, not both.
getWriter
in interface ServletResponse
javax.servlet.ServletResponse
PrintWriter
object that
can return character data to the clientUnsupportedEncodingException
- if the charset specified in
setContentType
cannot be
usedIllegalStateException
- if the getOutputStream
method has already been called for this
response objectIOException
- if an input or output exception occurredServletResponse.getOutputStream()
,
ServletResponse.setContentType(java.lang.String)
public void setBufferSize(int size) throws IllegalStateException
ServletResponse
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
.
setBufferSize
in interface ServletResponse
javax.servlet.ServletResponse
size
- the preferred buffer sizeIllegalStateException
- if this method is called after
content has been writtenServletResponse.getBufferSize()
,
ServletResponse.flushBuffer()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public int getBufferSize()
ServletResponse
getBufferSize
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.flushBuffer()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public void reset() throws IllegalStateException
ServletResponse
IllegalStateException
.reset
in interface ServletResponse
javax.servlet.ServletResponse
IllegalStateException
- if the response has already been
committedServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.flushBuffer()
,
ServletResponse.isCommitted()
public boolean isCommitted()
ServletResponse
isCommitted
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.flushBuffer()
,
ServletResponse.reset()
public void flushBuffer() throws IOException
ServletResponse
flushBuffer
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setBufferSize(int)
,
ServletResponse.getBufferSize()
,
ServletResponse.isCommitted()
,
ServletResponse.reset()
public void setLocale(Locale loc)
ServletResponse
ServletResponse.getWriter()
. By default, the response locale
is the default locale for the server.setLocale
in interface ServletResponse
javax.servlet.ServletResponse
loc
- the locale of the responseServletResponse.getLocale()
public Locale getLocale()
ServletResponse
getLocale
in interface ServletResponse
javax.servlet.ServletResponse
ServletResponse.setLocale(java.util.Locale)
public void addCookie(Cookie cookie)
HttpServletResponse
addCookie
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
cookie
- the Cookie to return to the clientpublic boolean containsHeader(String name)
HttpServletResponse
containsHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the header nametrue
if the named response header
has already been set;
false
otherwisepublic void setStatus(int sc, String sm)
setStatus
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the status codesm
- the status messagepublic void setStatus(int sc)
HttpServletResponse
sendError
method should be used
instead.setStatus
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the status codeHttpServletResponse.sendError(int, java.lang.String)
public void setHeader(String name, String value)
HttpServletResponse
containsHeader
method can be
used to test for the presence of a header before setting its
value.setHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the header valueHttpServletResponse.containsHeader(java.lang.String)
,
HttpServletResponse.addHeader(java.lang.String, java.lang.String)
public void setIntHeader(String name, int value)
HttpServletResponse
containsHeader
method can be used to test for the presence of a header before
setting its value.setIntHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the assigned integer valueHttpServletResponse.containsHeader(java.lang.String)
,
HttpServletResponse.addIntHeader(java.lang.String, int)
public void setDateHeader(String name, long date)
HttpServletResponse
containsHeader
method can be used to test for the
presence of a header before setting its value.setDateHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the header to setvalue
- the assigned date valueHttpServletResponse.containsHeader(java.lang.String)
,
HttpServletResponse.addDateHeader(java.lang.String, long)
public void sendError(int sc, String msg) throws IOException
HttpServletResponse
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the error status codemsg
- the descriptive messageIOException
- If an input or output exception occursIllegalStateException
- If the response was committed
before this method callpublic void sendError(int sc) throws IOException
HttpServletResponse
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendError
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
sc
- the error status codeIOException
- If an input or output exception occursIllegalStateException
- If the response was committedpublic void sendRedirect(String location) throws IOException
HttpServletResponse
If the response has already been committed, this method throws an IllegalStateException. After using this method, the response should be considered to be committed and should not be written to.
sendRedirect
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
location
- the redirect location URLIOException
- If an input or output exception occursIllegalStateException
- If the response was committedpublic String encodeURL(String url)
HttpServletResponse
For robust session tracking, all URLs emitted by a servlet should be run through this method. Otherwise, URL rewriting cannot be used with browsers which do not support cookies.
encodeURL
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.public String encodeRedirectURL(String url)
HttpServletResponse
sendRedirect
method or, if encoding is not needed,
returns the URL unchanged. The implementation of this method
includes the logic to determine whether the session ID
needs to be encoded in the URL. Because the rules for making
this determination can differ from those used to decide whether to
encode a normal link, this method is seperate from the
encodeURL
method.
All URLs sent to the HttpServletResponse.sendRedirect
method should be run through this method. Otherwise, URL
rewriting cannot be used with browsers which do not support
cookies.
encodeRedirectURL
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.HttpServletResponse.sendRedirect(java.lang.String)
,
HttpServletResponse.encodeUrl(java.lang.String)
public void addHeader(String name, String value)
HttpServletResponse
addHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the additional header valueHttpServletResponse.setHeader(java.lang.String, java.lang.String)
public void addDateHeader(String name, long value)
HttpServletResponse
addDateHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the header to setvalue
- the additional date valueHttpServletResponse.setDateHeader(java.lang.String, long)
public void addIntHeader(String name, int value)
HttpServletResponse
addIntHeader
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
name
- the name of the headervalue
- the assigned integer valueHttpServletResponse.setIntHeader(java.lang.String, int)
public String encodeUrl(String url)
HttpServletResponse.encodeURL(java.lang.String)
.
encodeUrl
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.public String encodeRedirectUrl(String url)
HttpServletResponse.encodeRedirectURL(java.lang.String)
.
encodeRedirectUrl
in interface HttpServletResponse
javax.servlet.http.HttpServletResponse
url
- the url to be encoded.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |