|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.cocoon.environment.http.HttpResponse
public final class HttpResponse
Implements the Response
interface
to provide response functionality in the HTTP servlets environment.
Constructor Summary | |
---|---|
protected |
HttpResponse(HttpServletResponse res)
Creates a HttpServletResponse based on a real HttpServletResponse object |
Method Summary | |
---|---|
void |
addCookie(Cookie cookie)
Adds the specified cookie to the response. |
void |
addDateHeader(String name,
long date)
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 int value. |
boolean |
containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set. |
Cookie |
createCookie(String name,
String value)
Create a new cookie which is not added to the response |
String |
encodeRedirectUrl(String url)
Deprecated. As of version 2.1, use encodeRedirectURL(String url) instead |
String |
encodeRedirectURL(String url)
|
String |
encodeUrl(String url)
Deprecated. As of version 2.1, use encodeURL(String url) instead |
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()
|
int |
getBufferSize()
|
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()
|
PrintWriter |
getWriter()
|
boolean |
isCommitted()
|
void |
reset()
|
void |
sendError(int sc)
|
void |
sendError(int sc,
String msg)
|
void |
sendPermanentRedirect(String location)
|
void |
sendRedirect(String location)
|
void |
setBufferSize(int size)
|
void |
setContentLength(int len)
|
void |
setContentType(String type)
|
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 int 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)
|
void |
setStatus(int sc,
String sm)
Deprecated. As of version 2.1, due to ambiguous meaning of the message parameter. To set a status code use setStatus(int) , to send an error with a description
use sendError(int, String) . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected HttpResponse(HttpServletResponse res)
Method Detail |
---|
public Cookie createCookie(String name, String value)
createCookie
in interface Response
name
- a String
specifying the name of the cookievalue
- a String
specifying the value of the cookiepublic void addCookie(Cookie cookie)
Response
addCookie
in interface Response
cookie
- the Cookie to return to the clientpublic boolean containsHeader(String name)
Response
containsHeader
in interface Response
name
- the header name
true
if the named response header
has already been set;
false
otherwisepublic String encodeURL(String url)
Response
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 Response
url
- the url to be encoded.
public String encodeRedirectURL(String url)
public void sendError(int sc, String msg) throws IOException
IOException
public void sendError(int sc) throws IOException
IOException
public void sendRedirect(String location) throws IOException
IOException
public void sendPermanentRedirect(String location) throws IOException
IOException
public void setDateHeader(String name, long date)
Response
containsHeader
method can be used to test for the
presence of a header before setting its value.
setDateHeader
in interface Response
name
- the name of the header to setdate
- the assigned date valueResponse.containsHeader(String)
,
Response.addDateHeader(String, long)
public void addDateHeader(String name, long date)
Response
addDateHeader
in interface Response
name
- the name of the header to setdate
- the additional date valueResponse.setDateHeader(String, long)
public void setHeader(String name, String value)
Response
containsHeader
method can be
used to test for the presence of a header before setting its
value.
setHeader
in interface Response
name
- the name of the headervalue
- the header valueResponse.containsHeader(String)
,
Response.addHeader(String, String)
public void addHeader(String name, String value)
Response
addHeader
in interface Response
name
- the name of the headervalue
- the additional header valueResponse.setHeader(String, String)
public void setIntHeader(String name, int value)
Response
containsHeader
method can be used to test for the
presence of a header before setting its value.
setIntHeader
in interface Response
name
- the name of the header to setvalue
- the assigned int valueResponse.containsHeader(String)
,
Response.addIntHeader(String, int)
public void addIntHeader(String name, int value)
Response
addIntHeader
in interface Response
name
- the name of the header to setvalue
- the additional int valueResponse.setIntHeader(String, int)
public void setStatus(int sc)
public String encodeUrl(String url)
public String encodeRedirectUrl(String url)
public void setStatus(int sc, String sm)
setStatus(int)
, to send an error with a description
use sendError(int, String)
.
public String getCharacterEncoding()
Response
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 Response
String
specifying the
name of the charset, for
example, ISO-8859-1
public ServletOutputStream getOutputStream() throws IOException
IOException
public PrintWriter getWriter() throws IOException
IOException
public void setContentLength(int len)
public void setContentType(String type)
public void setBufferSize(int size)
public int getBufferSize()
public void flushBuffer() throws IOException
IOException
public boolean isCommitted()
public void reset()
public void setLocale(Locale loc)
Response
setLocale
in interface Response
loc
- the locale of the responseResponse.getLocale()
public Locale getLocale()
Response
getLocale
in interface Response
Response.setLocale(Locale)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |