Top Description Fields Constructors Methods
jakarta.servlet

public Class ServletResponseWrapper

extends Object
implements ServletResponse
Class Inheritance
All Implemented Interfaces
jakarta.servlet.ServletResponse
Known Direct Subclasses
jakarta.servlet.http.HttpServletResponseWrapper, org.apache.catalina.core.ApplicationResponse
Imports
java.io.IOException, .PrintWriter, java.util.Locale, .ResourceBundle

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
See Also
jakarta.servlet.ServletResponse

Field Summary

Modifier and TypeField and Description
private static final String
private static final ResourceBundle
private ServletResponse

Constructor Summary

AccessConstructor and Description
public
ServletResponseWrapper(ServletResponse
The response to wrap
response
)

Creates a ServletResponse adaptor wrapping the given response object.

Method Summary

Modifier and TypeMethod and Description
public void
flushBuffer()

Implements jakarta.servlet.ServletResponse.flushBuffer.

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

public int
getBufferSize()

Implements jakarta.servlet.ServletResponse.getBufferSize.

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

public String
getCharacterEncoding()

Implements jakarta.servlet.ServletResponse.getCharacterEncoding.

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

public String
getContentType()

Implements jakarta.servlet.ServletResponse.getContentType.

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

public Locale
getLocale()

Implements jakarta.servlet.ServletResponse.getLocale.

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

public ServletOutputStream
getOutputStream()

Implements jakarta.servlet.ServletResponse.getOutputStream.

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

public ServletResponse

Returns:

The wrapped ServletResponse object.
getResponse
()

Return the wrapped ServletResponse object.

public PrintWriter
getWriter()

Implements jakarta.servlet.ServletResponse.getWriter.

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

public boolean
isCommitted()

Implements jakarta.servlet.ServletResponse.isCommitted.

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

public boolean

Returns:

true if the response wrapped by this wrapper (or series of wrappers) is the same as the supplied response, otherwise false
isWrapperFor
(ServletResponse
The response to compare to the wrapped response
wrapped
)

TODO SERVLET3 - Add comments

public boolean

Returns:

true if the response wrapped by this wrapper (or series of wrappers) is the same type as the supplied type, otherwise false
isWrapperFor
(Class<?>
The class to compare to the class of the wrapped response
wrappedType
)

TODO SERVLET3 - Add comments

public void
reset()

Implements jakarta.servlet.ServletResponse.reset.

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

public void
resetBuffer()

Implements jakarta.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 jakarta.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 jakarta.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 jakarta.servlet.ServletResponse.setContentLength.

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

public void
setContentLengthLong(long
an integer specifying the length of the content being returned to the client; sets the Content-Length header
length
)

Implements jakarta.servlet.ServletResponse.setContentLengthLong.

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

public void
setContentType(String
a String specifying the MIME type of the content
type
)

Implements jakarta.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 jakarta.servlet.ServletResponse.setLocale.

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

public void
setResponse(ServletResponse
The new response to wrap
response
)

Sets the response being wrapped.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LSTRING_FILEback to summary
private static final String LSTRING_FILE
lStringsback to summary
private static final ResourceBundle lStrings
responseback to summary
private ServletResponse response

Constructor Detail

ServletResponseWrapperback to summary
public ServletResponseWrapper(ServletResponse response)

Creates a ServletResponse adaptor wrapping the given response object.

Parameters
response:ServletResponse

The response to wrap

Exceptions
IllegalArgumentException:
if the response is null.

Method Detail

flushBufferback to summary
public void flushBuffer() throws IOException

Implements jakarta.servlet.ServletResponse.flushBuffer.

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

Annotations
@Override
Exceptions
IOException:

Doc from jakarta.servlet.ServletResponse.flushBuffer.

if an I/O occurs during the flushing of the response

getBufferSizeback to summary
public int getBufferSize()

Implements jakarta.servlet.ServletResponse.getBufferSize.

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

Returns:int

Doc from jakarta.servlet.ServletResponse.getBufferSize.

the actual buffer size used

Annotations
@Override
getCharacterEncodingback to summary
public String getCharacterEncoding()

Implements jakarta.servlet.ServletResponse.getCharacterEncoding.

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

Returns:String

Doc from jakarta.servlet.ServletResponse.getCharacterEncoding.

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

Annotations
@Override
getContentTypeback to summary
public String getContentType()

Implements jakarta.servlet.ServletResponse.getContentType.

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

Returns:String

Doc from jakarta.servlet.ServletResponse.getContentType.

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

Annotations
@Override
Since
Servlet 2.4
getLocaleback to summary
public Locale getLocale()

Implements jakarta.servlet.ServletResponse.getLocale.

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

Returns:Locale

Doc from jakarta.servlet.ServletResponse.getLocale.

The locale specified for this response using the setLocale method. If no locale has been specified, the container's default locale is returned.

Annotations
@Override
getOutputStreamback to summary
public ServletOutputStream getOutputStream() throws IOException

Implements jakarta.servlet.ServletResponse.getOutputStream.

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

Returns:ServletOutputStream

Doc from jakarta.servlet.ServletResponse.getOutputStream.

a ServletOutputStream for writing binary data

Annotations
@Override
Exceptions
IOException:

Doc from jakarta.servlet.ServletResponse.getOutputStream.

if an input or output exception occurred

getResponseback to summary
public ServletResponse getResponse()

Return the wrapped ServletResponse object.

Returns:ServletResponse

The wrapped ServletResponse object.

getWriterback to summary
public PrintWriter getWriter() throws IOException

Implements jakarta.servlet.ServletResponse.getWriter.

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

Returns:PrintWriter

Doc from jakarta.servlet.ServletResponse.getWriter.

a PrintWriter object that can return character data to the client

Annotations
@Override
Exceptions
IOException:

Doc from jakarta.servlet.ServletResponse.getWriter.

if an input or output exception occurred

isCommittedback to summary
public boolean isCommitted()

Implements jakarta.servlet.ServletResponse.isCommitted.

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

Returns:boolean

Doc from jakarta.servlet.ServletResponse.isCommitted.

a boolean indicating if the response has been committed

Annotations
@Override
isWrapperForback to summary
public boolean isWrapperFor(ServletResponse wrapped)

TODO SERVLET3 - Add comments

Parameters
wrapped:ServletResponse

The response to compare to the wrapped response

Returns:boolean

true if the response wrapped by this wrapper (or series of wrappers) is the same as the supplied response, otherwise false

Since
Servlet 3.0
isWrapperForback to summary
public boolean isWrapperFor(Class<?> wrappedType)

TODO SERVLET3 - Add comments

Parameters
wrappedType:Class<?>

The class to compare to the class of the wrapped response

Returns:boolean

true if the response wrapped by this wrapper (or series of wrappers) is the same type as the supplied type, otherwise false

Since
Servlet 3.0
resetback to summary
public void reset()

Implements jakarta.servlet.ServletResponse.reset.

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

Annotations
@Override
resetBufferback to summary
public void resetBuffer()

Implements jakarta.servlet.ServletResponse.resetBuffer.

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

Annotations
@Override
setBufferSizeback to summary
public void setBufferSize(int size)

Implements jakarta.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 jakarta.servlet.ServletResponse.setBufferSize.

the preferred buffer size

Annotations
@Override
setCharacterEncodingback to summary
public void setCharacterEncoding(String charset)

Implements jakarta.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 jakarta.servlet.ServletResponse.setCharacterEncoding.

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

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

Implements jakarta.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 jakarta.servlet.ServletResponse.setContentLength.

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

Annotations
@Override
setContentLengthLongback to summary
public void setContentLengthLong(long length)

Implements jakarta.servlet.ServletResponse.setContentLengthLong.

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

Parameters
length:long

Doc from jakarta.servlet.ServletResponse.setContentLengthLong.

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

Annotations
@Override
Since
Servlet 3.1
setContentTypeback to summary
public void setContentType(String type)

Implements jakarta.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 jakarta.servlet.ServletResponse.setContentType.

a String specifying the MIME type of the content

Annotations
@Override
setLocaleback to summary
public void setLocale(Locale loc)

Implements jakarta.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 jakarta.servlet.ServletResponse.setLocale.

the locale of the response

Annotations
@Override
setResponseback to summary
public void setResponse(ServletResponse response)

Sets the response being wrapped.

Parameters
response:ServletResponse

The new response to wrap

Exceptions
IllegalArgumentException:
if the response is null.