|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.apache.commons.messagelet.impl.ServletResponseImpl org.apache.commons.messagelet.impl.HttpServletResponseImpl
public class HttpServletResponseImpl
Based on the HttpRequestBase code from Catalina.
Field Summary | |
---|---|
protected ArrayList |
cookies
The set of Cookies associated with this Response. |
protected static SimpleDateFormat |
format
The date format we will use for creating date headers. |
protected HashMap |
headers
The HTTP headers explicitly added via addHeader(), but not including those to be added with setContentLength(), setContentType(), and so on. |
protected String |
message
The error message set by sendError() . |
protected int |
status
The HTTP status code associated with this Response. |
protected static TimeZone |
zone
The time zone with which to construct date headers. |
Fields inherited from class org.apache.commons.messagelet.impl.ServletResponseImpl |
---|
buffer, bufferCount, committed, contentCount, contentLength, contentType, encoding, error, included, locale, output, stream, writer |
Fields inherited from interface javax.servlet.http.HttpServletResponse |
---|
SC_ACCEPTED, SC_BAD_GATEWAY, SC_BAD_REQUEST, SC_CONFLICT, SC_CONTINUE, SC_CREATED, SC_EXPECTATION_FAILED, SC_FORBIDDEN, SC_GATEWAY_TIMEOUT, SC_GONE, SC_HTTP_VERSION_NOT_SUPPORTED, SC_INTERNAL_SERVER_ERROR, SC_LENGTH_REQUIRED, SC_METHOD_NOT_ALLOWED, SC_MOVED_PERMANENTLY, SC_MOVED_TEMPORARILY, SC_MULTIPLE_CHOICES, SC_NO_CONTENT, SC_NON_AUTHORITATIVE_INFORMATION, SC_NOT_ACCEPTABLE, SC_NOT_FOUND, SC_NOT_IMPLEMENTED, SC_NOT_MODIFIED, SC_OK, SC_PARTIAL_CONTENT, SC_PAYMENT_REQUIRED, SC_PRECONDITION_FAILED, SC_PROXY_AUTHENTICATION_REQUIRED, SC_REQUEST_ENTITY_TOO_LARGE, SC_REQUEST_TIMEOUT, SC_REQUEST_URI_TOO_LONG, SC_REQUESTED_RANGE_NOT_SATISFIABLE, SC_RESET_CONTENT, SC_SEE_OTHER, SC_SERVICE_UNAVAILABLE, SC_SWITCHING_PROTOCOLS, SC_TEMPORARY_REDIRECT, SC_UNAUTHORIZED, SC_UNSUPPORTED_MEDIA_TYPE, SC_USE_PROXY |
Constructor Summary | |
---|---|
HttpServletResponseImpl()
|
Method Summary | |
---|---|
void |
addCookie(javax.servlet.http.Cookie cookie)
Add the specified Cookie to those that will be included with this Response. |
void |
addDateHeader(String name,
long value)
Add the specified date header to the specified value. |
void |
addHeader(String name,
String value)
Add the specified header to the specified value. |
void |
addIntHeader(String name,
int value)
Add the specified integer header to the specified value. |
boolean |
containsHeader(String name)
Has the specified header been set already in this response? |
String |
encodeRedirectUrl(String url)
Deprecated. As of Version 2.1 of the Java Servlet API, use encodeRedirectURL() instead. |
String |
encodeRedirectURL(String url)
Encode the session identifier associated with this response into the specified redirect URL, if necessary. |
String |
encodeUrl(String url)
Deprecated. As of Version 2.1 of the Java Servlet API, use encodeURL() instead. |
String |
encodeURL(String url)
Encode the session identifier associated with this response into the specified URL, if necessary. |
void |
flushBuffer()
Flush the buffer and commit this response. |
javax.servlet.http.Cookie[] |
getCookies()
Return an array of all cookies set for this response, or a zero-length array if no cookies have been set. |
String |
getHeader(String name)
Return the value for the specified header, or null if this
header has not been set. |
String[] |
getHeaderNames()
Return an array of all the header names set for this response, or a zero-length array if no headers have been set. |
String[] |
getHeaderValues(String name)
Return an array of all the header values associated with the specified header name, or an zero-length array if there are no such header values. |
String |
getMessage()
Return the error message that was set with sendError()
for this Response. |
int |
getStatus()
Return the HTTP status code associated with this Response. |
protected String |
getStatusMessage(int status)
Returns a default status message for the specified HTTP status code. |
void |
recycle()
Release all object references, and initialize instance variables, in preparation for reuse of this object. |
void |
reset()
Clear any content written to the buffer. |
void |
reset(int status,
String message)
Reset this response, and specify the values for the HTTP status code and corresponding message. |
void |
sendError(int status)
Send an error response with the specified status and a default message. |
void |
sendError(int status,
String message)
Send an error response with the specified status and message. |
void |
sendRedirect(String location)
Send a temporary redirect to the specified redirect location URL. |
void |
setContentLength(int length)
Set the content length (in bytes) for this Response. |
void |
setContentType(String type)
Set the content type for this Response. |
void |
setDateHeader(String name,
long value)
Set the specified date header to the specified value. |
void |
setHeader(String name,
String value)
Set the specified header to the specified value. |
void |
setIntHeader(String name,
int value)
Set the specified integer header to the specified value. |
void |
setLocale(Locale locale)
Set the Locale that is appropriate for this response, including setting the appropriate character encoding. |
void |
setStatus(int status)
Set the HTTP status to be returned with this response. |
void |
setStatus(int status,
String message)
Deprecated. As of Version 2.1 of the Java Servlet API, this method has been deprecated due to the ambiguous meaning of the message parameter. |
Methods inherited from class org.apache.commons.messagelet.impl.ServletResponseImpl |
---|
createOutputStream, finishResponse, getBufferSize, getCharacterEncoding, getContentCount, getContentLength, getContentType, getLocale, getOutputStream, getStream, getWriter, isCommitted, resetBuffer, setBufferSize, setStream |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface javax.servlet.ServletResponse |
---|
getBufferSize, getCharacterEncoding, getLocale, getOutputStream, getWriter, isCommitted, resetBuffer, setBufferSize |
Field Detail |
---|
protected ArrayList cookies
protected static final SimpleDateFormat format
protected HashMap headers
protected String message
sendError()
.
protected int status
protected static final TimeZone zone
Constructor Detail |
---|
public HttpServletResponseImpl()
Method Detail |
---|
public javax.servlet.http.Cookie[] getCookies()
public String getHeader(String name)
null
if this
header has not been set. If more than one value was added for this
name, only the first is returned; use getHeaderValues() to retrieve all
of them.
name
- Header name to look uppublic String[] getHeaderNames()
public String[] getHeaderValues(String name)
name
- Header name to look uppublic String getMessage()
sendError()
for this Response.
public int getStatus()
public void recycle()
public void reset(int status, String message)
IllegalStateException
- if this response has already been
committedprotected String getStatusMessage(int status)
status
- The status code for which a message is desiredpublic void flushBuffer() throws IOException
flushBuffer
in interface javax.servlet.ServletResponse
flushBuffer
in class ServletResponseImpl
IOException
- if an input/output error occurspublic void reset()
reset
in interface javax.servlet.ServletResponse
reset
in class ServletResponseImpl
IllegalStateException
- if this response has already
been committedpublic void setContentLength(int length)
setContentLength
in interface javax.servlet.ServletResponse
setContentLength
in class ServletResponseImpl
length
- The new content lengthpublic void setContentType(String type)
setContentType
in interface javax.servlet.ServletResponse
setContentType
in class ServletResponseImpl
type
- The new content typepublic void setLocale(Locale locale)
setLocale
in interface javax.servlet.ServletResponse
setLocale
in class ServletResponseImpl
locale
- The new localepublic void addCookie(javax.servlet.http.Cookie cookie)
addCookie
in interface javax.servlet.http.HttpServletResponse
cookie
- Cookie to be addedpublic void addDateHeader(String name, long value)
addDateHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to setvalue
- Date value to be setpublic void addHeader(String name, String value)
addHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to setvalue
- Value to be setpublic void addIntHeader(String name, int value)
addIntHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to setvalue
- Integer value to be setpublic boolean containsHeader(String name)
containsHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to checkpublic String encodeRedirectURL(String url)
encodeRedirectURL
in interface javax.servlet.http.HttpServletResponse
url
- URL to be encodedpublic String encodeRedirectUrl(String url)
encodeRedirectURL()
instead.
encodeRedirectUrl
in interface javax.servlet.http.HttpServletResponse
url
- URL to be encodedpublic String encodeURL(String url)
encodeURL
in interface javax.servlet.http.HttpServletResponse
url
- URL to be encodedpublic String encodeUrl(String url)
encodeURL()
instead.
encodeUrl
in interface javax.servlet.http.HttpServletResponse
url
- URL to be encodedpublic void sendError(int status) throws IOException
sendError
in interface javax.servlet.http.HttpServletResponse
status
- HTTP status code to send
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void sendError(int status, String message) throws IOException
sendError
in interface javax.servlet.http.HttpServletResponse
status
- HTTP status code to sendmessage
- Corresponding message to send
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void sendRedirect(String location) throws IOException
sendRedirect
in interface javax.servlet.http.HttpServletResponse
location
- Location URL to redirect to
IllegalStateException
- if this response has
already been committed
IOException
- if an input/output error occurspublic void setDateHeader(String name, long value)
setDateHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to setvalue
- Date value to be setpublic void setHeader(String name, String value)
setHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to setvalue
- Value to be setpublic void setIntHeader(String name, int value)
setIntHeader
in interface javax.servlet.http.HttpServletResponse
name
- Name of the header to setvalue
- Integer value to be setpublic void setStatus(int status)
setStatus
in interface javax.servlet.http.HttpServletResponse
status
- The new HTTP statuspublic void setStatus(int status, String message)
setStatus
in interface javax.servlet.http.HttpServletResponse
status
- The new HTTP statusmessage
- The associated text message
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |