Top Description Fields Constructors Methods
javax.servlet

public Class ServletResponseWrapper

extends Object
implements ServletResponse
Class Inheritance
All Implemented Interfaces
javax.servlet.ServletResponse
Known Direct Subclasses
javax.servlet.http.HttpServletResponseWrapper
Imports
java.io.IOException, .PrintWriter, java.util.Locale

Provides a convenient implementation of the ServletResponse 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.ServletResponse

Field Summary

Modifier and TypeField and Description
private ServletResponse

Constructor Summary

AccessConstructor and Description
public
ServletResponseWrapper(ServletResponse response)

Creates a ServletResponse adaptor wrapping the given response object.

Method Summary

Modifier and TypeMethod and Description
public void
flushBuffer()

Implements javax.servlet.ServletResponse.flushBuffer.

The default behavior of this method is to call flushBuffer() on the wrapped response object.
public int
getBufferSize()

Implements javax.servlet.ServletResponse.getBufferSize.

The default behavior of this method is to return getBufferSize() on the wrapped response object.
public String
getCharacterEncoding()

Implements javax.servlet.ServletResponse.getCharacterEncoding.

The default behavior of this method is to return getCharacterEncoding() on the wrapped response object.
public String
getContentType()

Implements javax.servlet.ServletResponse.getContentType.

The default behavior of this method is to return getContentType() on the wrapped response object.
public Locale
getLocale()

Implements javax.servlet.ServletResponse.getLocale.

The default behavior of this method is to return getLocale() on the wrapped response object.
public ServletOutputStream
getOutputStream()

Implements javax.servlet.ServletResponse.getOutputStream.

The default behavior of this method is to return getOutputStream() on the wrapped response object.
public ServletResponse
getResponse()

Return the wrapped ServletResponse object.

public PrintWriter
getWriter()

Implements javax.servlet.ServletResponse.getWriter.

The default behavior of this method is to return getWriter() on the wrapped response object.
public boolean
isCommitted()

Implements javax.servlet.ServletResponse.isCommitted.

The default behavior of this method is to return isCommitted() on the wrapped response object.
public void
reset()

Implements javax.servlet.ServletResponse.reset.

The default behavior of this method is to call reset() on the wrapped response object.
public void
resetBuffer()

Implements javax.servlet.ServletResponse.resetBuffer.

The default behavior of this method is to call resetBuffer() on the wrapped response object.
public void
setBufferSize(int
the preferred buffer size
size
)

Implements javax.servlet.ServletResponse.setBufferSize.

The default behavior of this method is to call setBufferSize(int size) on the wrapped response object.
public void
setCharacterEncoding(String
a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)
charset
)

Implements javax.servlet.ServletResponse.setCharacterEncoding.

The default behavior of this method is to call setCharacterEncoding(String charset) on the wrapped response object.
public void
setContentLength(int
an integer specifying the length of the content being returned to the client; sets the Content-Length header
len
)

Implements javax.servlet.ServletResponse.setContentLength.

The default behavior of this method is to call setContentLength(int len) on the wrapped response object.
public void
setContentType(String
a String specifying the MIME type of the content
type
)

Implements javax.servlet.ServletResponse.setContentType.

The default behavior of this method is to call setContentType(String type) on the wrapped response object.
public void
setLocale(Locale
the locale of the response
loc
)

Implements javax.servlet.ServletResponse.setLocale.

The default behavior of this method is to call setLocale(Locale loc) on the wrapped response object.
public void
setResponse(ServletResponse response)

Sets the response being wrapped.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

responseback to summary
private ServletResponse response

Constructor Detail

ServletResponseWrapperback to summary
public ServletResponseWrapper(ServletResponse response)

Creates a ServletResponse adaptor wrapping the given response object.

Exceptions
IllegalArgumentException:
if the response is null.

Method Detail

flushBufferback to summary
public void flushBuffer() throws IOException

Implements javax.servlet.ServletResponse.flushBuffer.

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

getBufferSizeback to summary
public int getBufferSize()

Implements javax.servlet.ServletResponse.getBufferSize.

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

Returns:int

Doc from javax.servlet.ServletResponse.getBufferSize.

the actual buffer size used

getCharacterEncodingback to summary
public String getCharacterEncoding()

Implements javax.servlet.ServletResponse.getCharacterEncoding.

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

Returns:String

Doc from javax.servlet.ServletResponse.getCharacterEncoding.

a String specifying the name of the character encoding, for example, UTF-8

getContentTypeback to summary
public String getContentType()

Implements javax.servlet.ServletResponse.getContentType.

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

Returns:String

Doc from javax.servlet.ServletResponse.getContentType.

a String specifying the content type, for example, text/html; charset=UTF-8, or null

Since
Servlet 2.4
getLocaleback to summary
public Locale getLocale()

Implements javax.servlet.ServletResponse.getLocale.

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

getOutputStreamback to summary
public ServletOutputStream getOutputStream() throws IOException

Implements javax.servlet.ServletResponse.getOutputStream.

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

Returns:ServletOutputStream

Doc from javax.servlet.ServletResponse.getOutputStream.

a ServletOutputStream for writing binary data

Exceptions
IOException:

Doc from javax.servlet.ServletResponse.getOutputStream.

if an input or output exception occurred

getResponseback to summary
public ServletResponse getResponse()

Return the wrapped ServletResponse object.

getWriterback to summary
public PrintWriter getWriter() throws IOException

Implements javax.servlet.ServletResponse.getWriter.

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

Returns:PrintWriter

Doc from javax.servlet.ServletResponse.getWriter.

a PrintWriter object that can return character data to the client

Exceptions
IOException:

Doc from javax.servlet.ServletResponse.getWriter.

if an input or output exception occurred

isCommittedback to summary
public boolean isCommitted()

Implements javax.servlet.ServletResponse.isCommitted.

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

Returns:boolean

Doc from javax.servlet.ServletResponse.isCommitted.

a boolean indicating if the response has been committed

resetback to summary
public void reset()

Implements javax.servlet.ServletResponse.reset.

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

resetBufferback to summary
public void resetBuffer()

Implements javax.servlet.ServletResponse.resetBuffer.

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

setBufferSizeback to summary
public void setBufferSize(int size)

Implements javax.servlet.ServletResponse.setBufferSize.

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

Parameters
size:int

Doc from javax.servlet.ServletResponse.setBufferSize.

the preferred buffer size

setCharacterEncodingback to summary
public void setCharacterEncoding(String charset)

Implements javax.servlet.ServletResponse.setCharacterEncoding.

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

Parameters
charset:String

Doc from javax.servlet.ServletResponse.setCharacterEncoding.

a String specifying only the character set defined by IANA Character Sets (http://www.iana.org/assignments/character-sets)

Since
Servlet 2.4
setContentLengthback to summary
public void setContentLength(int len)

Implements javax.servlet.ServletResponse.setContentLength.

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

Parameters
len:int

Doc from javax.servlet.ServletResponse.setContentLength.

an integer specifying the length of the content being returned to the client; sets the Content-Length header

setContentTypeback to summary
public void setContentType(String type)

Implements javax.servlet.ServletResponse.setContentType.

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

Parameters
type:String

Doc from javax.servlet.ServletResponse.setContentType.

a String specifying the MIME type of the content

setLocaleback to summary
public void setLocale(Locale loc)

Implements javax.servlet.ServletResponse.setLocale.

The default behavior of this method is to call setLocale(Locale loc) on the wrapped response object.

Parameters
loc:Locale

Doc from javax.servlet.ServletResponse.setLocale.

the locale of the response

setResponseback to summary
public void setResponse(ServletResponse response)

Sets the response being wrapped.

Exceptions
IllegalArgumentException:
if the response is null.