Top Description Constructors Methods
javax.servlet.http

public Class HttpServletResponseWrapper

extends ServletResponseWrapper
implements HttpServletResponse
Class Inheritance
All Implemented Interfaces
javax.servlet.http.HttpServletResponse, javax.servlet.ServletResponse
Imports
java.io.IOException, javax.servlet.ServletResponseWrapper

Provides a convenient implementation of the HttpServletResponse interface that can be subclassed by developers wishing to adapt the response from a Servlet. This class implements the Wrapper or Decorator pattern. Methods default to calling through to the wrapped response object.
Since
Servlet 2.3
Version
$Rev: 46019 $ $Date: 2004-09-14 04:56:06 -0500 (Tue, 14 Sep 2004) $
See Also
javax.servlet.http.HttpServletResponse

Constructor Summary

AccessConstructor and Description
public
HttpServletResponseWrapper(HttpServletResponse response)

Constructs a response adaptor wrapping the given response.

Method Summary

Modifier and TypeMethod and Description
private HttpServletResponse
public void
addCookie(Cookie
the Cookie to return to the client
cookie
)

Implements javax.servlet.http.HttpServletResponse.addCookie.

The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object.
public void
addDateHeader(String
the name of the header to set
name
,
long
the additional date value
date
)

Implements javax.servlet.http.HttpServletResponse.addDateHeader.

The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object.
public void
addHeader(String
the name of the header
name
,
String
the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
value
)

Implements javax.servlet.http.HttpServletResponse.addHeader.

The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.
public void
addIntHeader(String
the name of the header
name
,
int
the assigned integer value
value
)

Implements javax.servlet.http.HttpServletResponse.addIntHeader.

The default behavior of this method is to call addIntHeader(String name, int value) on the wrapped response object.
public boolean
containsHeader(String
the header name
name
)

Implements javax.servlet.http.HttpServletResponse.containsHeader.

The default behavior of this method is to call containsHeader(String name) on the wrapped response object.
public String
encodeRedirectURL(String
the url to be encoded.
url
)

Implements javax.servlet.http.HttpServletResponse.encodeRedirectURL.

The default behavior of this method is to return encodeRedirectURL(String url) on the wrapped response object.
public String
encodeRedirectUrl(String
the url to be encoded.
url
)

Implements javax.servlet.http.HttpServletResponse.encodeRedirectUrl.

The default behavior of this method is to return encodeRedirectUrl(String url) on the wrapped response object.
public String
encodeURL(String
the url to be encoded.
url
)

Implements javax.servlet.http.HttpServletResponse.encodeURL.

The default behavior of this method is to call encodeURL(String url) on the wrapped response object.
public String
encodeUrl(String
the url to be encoded.
url
)

Implements javax.servlet.http.HttpServletResponse.encodeUrl.

The default behavior of this method is to call encodeUrl(String url) on the wrapped response object.
public void
sendError(int
the error status code
sc
,
String
the descriptive message
msg
)

Implements javax.servlet.http.HttpServletResponse.sendError.

The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.
public void
sendError(int
the error status code
sc
)

Implements javax.servlet.http.HttpServletResponse.sendError.

The default behavior of this method is to call sendError(int sc) on the wrapped response object.
public void
sendRedirect(String
the redirect location URL
location
)

Implements javax.servlet.http.HttpServletResponse.sendRedirect.

The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.
public void
setDateHeader(String
the name of the header to set
name
,
long
the assigned date value
date
)

Implements javax.servlet.http.HttpServletResponse.setDateHeader.

The default behavior of this method is to call setDateHeader(String name, long date) on the wrapped response object.
public void
setHeader(String
the name of the header
name
,
String
the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)
value
)

Implements javax.servlet.http.HttpServletResponse.setHeader.

The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.
public void
setIntHeader(String
the name of the header
name
,
int
the assigned integer value
value
)

Implements javax.servlet.http.HttpServletResponse.setIntHeader.

The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.
public void
setStatus(int
the status code
sc
)

Implements javax.servlet.http.HttpServletResponse.setStatus.

The default behavior of this method is to call setStatus(int sc) on the wrapped response object.
public void
setStatus(int
the status code
sc
,
String
the status message
sm
)

Implements javax.servlet.http.HttpServletResponse.setStatus.

The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object.
Inherited from javax.servlet.ServletResponseWrapper:
flushBuffergetBufferSizegetCharacterEncodinggetContentTypegetLocalegetOutputStreamgetResponsegetWriterisCommittedresetresetBuffersetBufferSizesetCharacterEncodingsetContentLengthsetContentTypesetLocalesetResponse

Constructor Detail

HttpServletResponseWrapperback to summary
public HttpServletResponseWrapper(HttpServletResponse response)

Constructs a response adaptor wrapping the given response.

Exceptions
IllegalArgumentException:
if the response is null

Method Detail

_getHttpServletResponseback to summary
private HttpServletResponse _getHttpServletResponse()
addCookieback to summary
public void addCookie(Cookie cookie)

Implements javax.servlet.http.HttpServletResponse.addCookie.

The default behavior of this method is to call addCookie(Cookie cookie) on the wrapped response object.

Parameters
cookie:Cookie

Doc from javax.servlet.http.HttpServletResponse.addCookie.

the Cookie to return to the client

addDateHeaderback to summary
public void addDateHeader(String name, long date)

Implements javax.servlet.http.HttpServletResponse.addDateHeader.

The default behavior of this method is to call addDateHeader(String name, long date) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.addDateHeader.

the name of the header to set

date:long

Doc from javax.servlet.http.HttpServletResponse.addDateHeader.

the additional date value

addHeaderback to summary
public void addHeader(String name, String value)

Implements javax.servlet.http.HttpServletResponse.addHeader.

The default behavior of this method is to return addHeader(String name, String value) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.addHeader.

the name of the header

value:String

Doc from javax.servlet.http.HttpServletResponse.addHeader.

the additional header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)

addIntHeaderback to summary
public void addIntHeader(String name, int value)

Implements javax.servlet.http.HttpServletResponse.addIntHeader.

The default behavior of this method is to call addIntHeader(String name, int value) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.addIntHeader.

the name of the header

value:int

Doc from javax.servlet.http.HttpServletResponse.addIntHeader.

the assigned integer value

containsHeaderback to summary
public boolean containsHeader(String name)

Implements javax.servlet.http.HttpServletResponse.containsHeader.

The default behavior of this method is to call containsHeader(String name) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.containsHeader.

the header name

Returns:boolean

Doc from javax.servlet.http.HttpServletResponse.containsHeader.

true if the named response header has already been set; false otherwise

encodeRedirectURLback to summary
public String encodeRedirectURL(String url)

Implements javax.servlet.http.HttpServletResponse.encodeRedirectURL.

The default behavior of this method is to return encodeRedirectURL(String url) on the wrapped response object.

Parameters
url:String

Doc from javax.servlet.http.HttpServletResponse.encodeRedirectURL.

the url to be encoded.

Returns:String

Doc from javax.servlet.http.HttpServletResponse.encodeRedirectURL.

the encoded URL if encoding is needed; the unchanged URL otherwise.

encodeRedirectUrlback to summary
public String encodeRedirectUrl(String url)

Implements javax.servlet.http.HttpServletResponse.encodeRedirectUrl.

The default behavior of this method is to return encodeRedirectUrl(String url) on the wrapped response object.

Parameters
url:String

Doc from javax.servlet.http.HttpServletResponse.encodeRedirectUrl.

the url to be encoded.

Returns:String

Doc from javax.servlet.http.HttpServletResponse.encodeRedirectUrl.

the encoded URL if encoding is needed; the unchanged URL otherwise.

encodeURLback to summary
public String encodeURL(String url)

Implements javax.servlet.http.HttpServletResponse.encodeURL.

The default behavior of this method is to call encodeURL(String url) on the wrapped response object.

Parameters
url:String

Doc from javax.servlet.http.HttpServletResponse.encodeURL.

the url to be encoded.

Returns:String

Doc from javax.servlet.http.HttpServletResponse.encodeURL.

the encoded URL if encoding is needed; the unchanged URL otherwise.

encodeUrlback to summary
public String encodeUrl(String url)

Implements javax.servlet.http.HttpServletResponse.encodeUrl.

The default behavior of this method is to call encodeUrl(String url) on the wrapped response object.

Parameters
url:String

Doc from javax.servlet.http.HttpServletResponse.encodeUrl.

the url to be encoded.

Returns:String

Doc from javax.servlet.http.HttpServletResponse.encodeUrl.

the encoded URL if encoding is needed; the unchanged URL otherwise.

sendErrorback to summary
public void sendError(int sc, String msg) throws IOException

Implements javax.servlet.http.HttpServletResponse.sendError.

The default behavior of this method is to call sendError(int sc, String msg) on the wrapped response object.

Parameters
sc:int

Doc from javax.servlet.http.HttpServletResponse.sendError.

the error status code

msg:String

Doc from javax.servlet.http.HttpServletResponse.sendError.

the descriptive message

Exceptions
IOException:

Doc from javax.servlet.http.HttpServletResponse.sendError.

If an input or output exception occurs

sendErrorback to summary
public void sendError(int sc) throws IOException

Implements javax.servlet.http.HttpServletResponse.sendError.

The default behavior of this method is to call sendError(int sc) on the wrapped response object.

Parameters
sc:int

Doc from javax.servlet.http.HttpServletResponse.sendError.

the error status code

Exceptions
IOException:

Doc from javax.servlet.http.HttpServletResponse.sendError.

If an input or output exception occurs

sendRedirectback to summary
public void sendRedirect(String location) throws IOException

Implements javax.servlet.http.HttpServletResponse.sendRedirect.

The default behavior of this method is to return sendRedirect(String location) on the wrapped response object.

Parameters
location:String

Doc from javax.servlet.http.HttpServletResponse.sendRedirect.

the redirect location URL

Exceptions
IOException:

Doc from javax.servlet.http.HttpServletResponse.sendRedirect.

If an input or output exception occurs

setDateHeaderback to summary
public void setDateHeader(String name, long date)

Implements javax.servlet.http.HttpServletResponse.setDateHeader.

The default behavior of this method is to call setDateHeader(String name, long date) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.setDateHeader.

the name of the header to set

date:long

Doc from javax.servlet.http.HttpServletResponse.setDateHeader.

the assigned date value

setHeaderback to summary
public void setHeader(String name, String value)

Implements javax.servlet.http.HttpServletResponse.setHeader.

The default behavior of this method is to return setHeader(String name, String value) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.setHeader.

the name of the header

value:String

Doc from javax.servlet.http.HttpServletResponse.setHeader.

the header value If it contains octet string, it should be encoded according to RFC 2047 (http://www.ietf.org/rfc/rfc2047.txt)

setIntHeaderback to summary
public void setIntHeader(String name, int value)

Implements javax.servlet.http.HttpServletResponse.setIntHeader.

The default behavior of this method is to call setIntHeader(String name, int value) on the wrapped response object.

Parameters
name:String

Doc from javax.servlet.http.HttpServletResponse.setIntHeader.

the name of the header

value:int

Doc from javax.servlet.http.HttpServletResponse.setIntHeader.

the assigned integer value

setStatusback to summary
public void setStatus(int sc)

Implements javax.servlet.http.HttpServletResponse.setStatus.

The default behavior of this method is to call setStatus(int sc) on the wrapped response object.

Parameters
sc:int

Doc from javax.servlet.http.HttpServletResponse.setStatus.

the status code

setStatusback to summary
public void setStatus(int sc, String sm)

Implements javax.servlet.http.HttpServletResponse.setStatus.

The default behavior of this method is to call setStatus(int sc, String sm) on the wrapped response object.

Parameters
sc:int

Doc from javax.servlet.http.HttpServletResponse.setStatus.

the status code

sm:String

Doc from javax.servlet.http.HttpServletResponse.setStatus.

the status message