Fields Summary |
---|
int | statusCode |
HashMap | headersThe HTTP headers explicitly added via addHeader(), but not including
those to be added with setContentLength(), setContentType(), and so on.
This collection is keyed by the header name, and the elements are
ArrayLists containing the associated values that have been set. |
HashMap | dateHeaderscache all the set/addDateHeader calls |
ArrayList | cookiesThe set of Cookies associated with this Response. |
int | contentLength |
String | contentType |
Locale | locale |
boolean | errorError flag. True if the response runs into an error.
treat the response to be in the error state if the servlet
doesn't get the OutpuStream or the Writer. |
CachingOutputStreamWrapper | coswOutputStream and PrintWriter objects for this response. |
PrintWriter | writer |
Methods Summary |
---|
public void | addCookie(javax.servlet.http.Cookie cookie)The default behavior of this method is to call addCookie(Cookie cookie)
on the wrapped response object.
super.addCookie(cookie);
synchronized (cookies) {
cookies.add(cookie);
}
|
public void | addDateHeader(java.lang.String name, long value)Add the specified date header to the specified value.
super.addDateHeader(name, value);
ArrayList values = (ArrayList) dateHeaders.get(name);
if (values == null) {
values = new ArrayList();
synchronized (dateHeaders) {
dateHeaders.put(name, values);
}
}
values.add(Long.valueOf(value));
|
public void | addHeader(java.lang.String name, java.lang.String value)Add the specified header to the specified value.
super.addHeader(name, value);
ArrayList values = (ArrayList) headers.get(name);
if (values == null) {
values = new ArrayList();
synchronized (headers) {
headers.put(name, values);
}
}
values.add(value);
|
public void | addIntHeader(java.lang.String name, int value)Add the specified integer header to the specified value.
addHeader(name, "" + value);
|
public HttpCacheEntry | cacheResponse()called by doFilter to cache the response that was just sent out
// create a new entry
HttpCacheEntry entry = new HttpCacheEntry();
entry.responseHeaders = headers;
entry.dateHeaders = dateHeaders;
entry.cookies = cookies;
entry.contentLength = contentLength;
entry.contentType = contentType;
entry.locale = locale;
entry.statusCode = statusCode;
// flush the writer??
if (writer != null) {
writer.flush();
}
entry.bytes = cosw.getBytes();
return entry;
|
public void | clear()clear the contents of this wrapper
cosw = null;
writer = null;
|
private CachingOutputStreamWrapper | createCachingOutputStreamWrapper()Create and return a ServletOutputStream to write the content
associated with this Response.
return new CachingOutputStreamWrapper();
|
public java.lang.Long | getExpiresDateHeader()return the Expires: date header value
return (Long)dateHeaders.get("Expires");
|
public javax.servlet.ServletOutputStream | getOutputStream()Return the servlet output stream associated with this Response.
if (writer != null)
throw new IllegalStateException ("getOutputStream<>getWriter");
if (cosw == null) {
cosw = createCachingOutputStreamWrapper();
}
error = false;
return (ServletOutputStream)cosw;
|
public java.io.PrintWriter | getWriter()Return the writer associated with this Response.
if (writer != null)
return (writer);
if (cosw != null)
throw new IllegalStateException ("getWriter<>getOutputStream");
cosw = createCachingOutputStreamWrapper();
OutputStreamWriter osw =
new OutputStreamWriter(cosw, getCharacterEncoding());
writer = new PrintWriter(osw);
error = false;
return (writer);
|
public boolean | isError()has the response been set to error
return error;
|
public void | sendError(int status)Send an error response with the specified status and a
default message.
super.sendError(status);
error = true;
|
public void | sendError(int status, java.lang.String message)Send an error response with the specified status and message.
super.sendError(status, message);
error = true;
|
public void | setContentLength(int len)Set the content length (in bytes) for this Response.
super.setContentLength(len);
this.contentLength = len;
|
public void | setContentType(java.lang.String type)Set the content type for this Response.
super.setContentType(type);
this.contentType = type;
|
public void | setDateHeader(java.lang.String name, long value)Set the specified date header to the specified value.
super.setDateHeader(name, value);
ArrayList values = new ArrayList();
values.add(Long.valueOf(value));
synchronized (dateHeaders) {
dateHeaders.put(name, values);
}
|
public void | setHeader(java.lang.String name, java.lang.String value)Set the specified header to the specified value.
super.setHeader(name, value);
ArrayList values = new ArrayList();
values.add(value);
synchronized (headers) {
headers.put(name, values);
}
|
public void | setIntHeader(java.lang.String name, int value)Set the specified integer header to the specified value.
setHeader(name, "" + value);
|
public void | setLocale(java.util.Locale locale)Set the Locale that is appropriate for this response, including
setting the appropriate character encoding.
super.setLocale(locale);
this.locale = locale;
|
public void | setStatus(int sc)Set the HTTP status to be returned with this response.
super.setStatus(sc);
this.statusCode = sc;
|