|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.faceless.util.HttpResponseWriter
public class HttpResponseWriter
Represents an outgoing HTTP Response. Unlike the HttpServletResponse class,
this class is not tied to a servlet context, and may be stored or manipulated
with ease.
Most of the methods in this class are identical to HttpServletResponse. Several are missing, namely those that need the Servlet Context to work (for example, encodeURL) and those dealing with the response buffer, which obviously don't apply to this class.
HttpResponseReader| Constructor Summary | |
|---|---|
HttpResponseWriter()
Create a new HttpResponseWriter |
|
HttpResponseWriter(HttpResponseReader reader)
Create a new HttpResponseWriter which is a copy of the specified HttpResponseReader. |
|
| Method Summary | |
|---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Adds the specified cookie to the response. |
void |
addCookie(String name,
String value,
String domain,
String path,
Date date,
boolean secure)
Adds the specified cookie to the response. |
void |
addDateHeader(String name,
long val)
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 val)
Sets a response header with the given name and integer value. |
void |
clearHeader(String name)
Remove the header from the response. |
boolean |
containsHeader(String name)
Returns a boolean indicating whether the named response header has already been set. |
String |
getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this response. |
String |
getHeader(String name)
Returns the value of the header if it's set, or null if it's not |
Locale |
getLocale()
Returns the locale assigned to the response |
OutputStream |
getOutputStream()
Returns an OutputStream suitable for writing binary data in the response. |
PrintWriter |
getWriter()
Returns a PrintWriter object that can send character text to the client. |
void |
reset()
Clears any data that exists in the buffer as well as the status code and headers. |
void |
resetBuffer()
Clears the content of the underlying buffer in the response without clearing headers or status code. |
void |
setContentType(String type)
Sets the content type of the response being sent to the client. |
void |
setDateHeader(String name,
long val)
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 val)
Adds 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 status)
Sets the status code for this response. |
void |
setStatus(int status,
String statusmsg)
Sets the status code for this response. |
void |
writeTo(javax.servlet.http.HttpServletResponse resp)
Write the response to the specified HttpServletResponse. |
void |
writeTo(OutputStream out)
Write the response to the specified OutputStream. |
| Methods inherited from class java.lang.Object |
|---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public HttpResponseWriter()
public HttpResponseWriter(HttpResponseReader reader)
throws IOException
IOException| Method Detail |
|---|
public void setHeader(String name,
String value)
name - the name of the headervalue - the header valuepublic String getHeader(String name)
name - the name of the header
public void addHeader(String name,
String value)
name - the name of the headervalue - the additional header valuepublic void clearHeader(String name)
name - the name of the headerpublic boolean containsHeader(String name)
name - the header name
public void setDateHeader(String name,
long val)
name - the name of the header to setvalue - the assigned date value
public void addDateHeader(String name,
long val)
name - the name of the header to setvalue - the additional date value
public void addIntHeader(String name,
int val)
name - the name of the headervalue - the assigned integer value
public void setIntHeader(String name,
int val)
name - the name of the headervalue - the assigned integer valuepublic void setLocale(Locale loc)
public Locale getLocale()
public void addCookie(javax.servlet.http.Cookie cookie)
cookie - the cookie to add to the response
public void addCookie(String name,
String value,
String domain,
String path,
Date date,
boolean secure)
name - the name of the cookievalue - the value of the cookiedomain - the domain of the cookie (optionally null)path - the path of the cookie (optionally null)date - the expiry date of the cookie (null for when the browser is closed, or a date in the past to delete the cookie)secure - whether the cookie should only be sent over secure connectionspublic String getCharacterEncoding()
Returns the name of the charset used for the MIME body sent in this 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.
public void setContentType(String type)
Sets the content type of the response being sent to the client. The content type may include the type of character encoding used, for example, text/html; charset=ISO-8859-4.
If obtaining a PrintWriter, this method should be called first.
type - a String specifying the MIME type of the contentpublic void setStatus(int status)
Unlike the same method in the HttpServletResponse class, this method does not clear the response buffer.
status - the status code, between 100 and 599
public void setStatus(int status,
String statusmsg)
Unlike the same method in the HttpServletResponse class, this method does not clear the response buffer.
status - the status code, between 100 and 599statusmsg - the status message to send
public PrintWriter getWriter()
throws UnsupportedEncodingException
Returns a PrintWriter object that can send character text to the client. The character encoding used is the one specified in the charset= property of the 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 getOutputStream() may be called to write the body, not both.
IllegalStateException - if the getOutputStream method has been called on this response
UnsupportedEncodingException - if the charset specified in setContentType cannot be usedpublic OutputStream getOutputStream()
Returns an OutputStream suitable for writing binary data in the response.
Either this method or getWriter() may be called to write the body, not both.
IllegalStateException - if the getWriter method has been called on this responsepublic void reset()
public void resetBuffer()
public void writeTo(javax.servlet.http.HttpServletResponse resp)
throws IOException
IOException
public void writeTo(OutputStream out)
throws IOException
IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||