Top Description Fields Constructors Methods
javax.servlet

public Class ServletRequestWrapper

extends Object
implements ServletRequest
Class Inheritance
All Implemented Interfaces
javax.servlet.ServletRequest
Known Direct Subclasses
javax.servlet.http.HttpServletRequestWrapper
Imports
java.io.BufferedReader, .IOException, java.util.Enumeration, .Locale, .Map

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

Field Summary

Modifier and TypeField and Description
private ServletRequest

Constructor Summary

AccessConstructor and Description
public
ServletRequestWrapper(ServletRequest request)

Creates a ServletRequest adaptor wrapping the given request object.

Method Summary

Modifier and TypeMethod and Description
public Object
getAttribute(String
a String specifying the name of the attribute
name
)

Implements javax.servlet.ServletRequest.getAttribute.

The default behavior of this method is to call getAttribute(String name) on the wrapped request object.
public Enumeration<E>
getAttributeNames()

Implements javax.servlet.ServletRequest.getAttributeNames.

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

Implements javax.servlet.ServletRequest.getCharacterEncoding.

The default behavior of this method is to return getCharacterEncoding() on the wrapped request object.
public int
getContentLength()

Implements javax.servlet.ServletRequest.getContentLength.

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

Implements javax.servlet.ServletRequest.getContentType.

The default behavior of this method is to return getContentType() on the wrapped request object.
public ServletInputStream
getInputStream()

Implements javax.servlet.ServletRequest.getInputStream.

The default behavior of this method is to return getInputStream() on the wrapped request object.
public String
getLocalAddr()

Implements javax.servlet.ServletRequest.getLocalAddr.

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

Implements javax.servlet.ServletRequest.getLocale.

The default behavior of this method is to return getLocale() on the wrapped request object.
public Enumeration<E>
getLocales()

Implements javax.servlet.ServletRequest.getLocales.

The default behavior of this method is to return getLocales() on the wrapped request object.
public String
getLocalName()

Implements javax.servlet.ServletRequest.getLocalName.

The default behavior of this method is to return getLocalName() on the wrapped request object.
public int
getLocalPort()

Implements javax.servlet.ServletRequest.getLocalPort.

The default behavior of this method is to return getLocalPort() on the wrapped request object.
public String
getParameter(String
a String specifying the name of the parameter
name
)

Implements javax.servlet.ServletRequest.getParameter.

The default behavior of this method is to return getParameter(String name) on the wrapped request object.
public Map<K, V>
getParameterMap()

Implements javax.servlet.ServletRequest.getParameterMap.

The default behavior of this method is to return getParameterMap() on the wrapped request object.
public Enumeration<E>
getParameterNames()

Implements javax.servlet.ServletRequest.getParameterNames.

The default behavior of this method is to return getParameterNames() on the wrapped request object.
public String[]
getParameterValues(String
a String containing the name of the parameter whose value is requested
name
)

Implements javax.servlet.ServletRequest.getParameterValues.

The default behavior of this method is to return getParameterValues(String name) on the wrapped request object.
public String
getProtocol()

Implements javax.servlet.ServletRequest.getProtocol.

The default behavior of this method is to return getProtocol() on the wrapped request object.
public BufferedReader
getReader()

Implements javax.servlet.ServletRequest.getReader.

The default behavior of this method is to return getReader() on the wrapped request object.
public String
getRealPath(String path)

Implements javax.servlet.ServletRequest.getRealPath.

The default behavior of this method is to return getRealPath(String path) on the wrapped request object.
public String
getRemoteAddr()

Implements javax.servlet.ServletRequest.getRemoteAddr.

The default behavior of this method is to return getRemoteAddr() on the wrapped request object.
public String
getRemoteHost()

Implements javax.servlet.ServletRequest.getRemoteHost.

The default behavior of this method is to return getRemoteHost() on the wrapped request object.
public int
getRemotePort()

Implements javax.servlet.ServletRequest.getRemotePort.

The default behavior of this method is to return getRemotePort() on the wrapped request object.
public ServletRequest
getRequest()

Return the wrapped request object.

public RequestDispatcher
getRequestDispatcher(String
a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.
path
)

Implements javax.servlet.ServletRequest.getRequestDispatcher.

The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object.
public String
getScheme()

Implements javax.servlet.ServletRequest.getScheme.

The default behavior of this method is to return getScheme() on the wrapped request object.
public String
getServerName()

Implements javax.servlet.ServletRequest.getServerName.

The default behavior of this method is to return getServerName() on the wrapped request object.
public int
getServerPort()

Implements javax.servlet.ServletRequest.getServerPort.

The default behavior of this method is to return getServerPort() on the wrapped request object.
public boolean
isSecure()

Implements javax.servlet.ServletRequest.isSecure.

The default behavior of this method is to return isSecure() on the wrapped request object.
public void
removeAttribute(String
a String specifying the name of the attribute to remove
name
)

Implements javax.servlet.ServletRequest.removeAttribute.

The default behavior of this method is to call removeAttribute(String name) on the wrapped request object.
public void
setAttribute(String
a String specifying the name of the attribute
name
,
Object
the Object to be stored
o
)

Implements javax.servlet.ServletRequest.setAttribute.

The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object.
public void
setCharacterEncoding(String
a String containing the name of the chararacter encoding.
enc
)

Implements javax.servlet.ServletRequest.setCharacterEncoding.

The default behavior of this method is to set the character encoding on the wrapped request object.
public void
setRequest(ServletRequest request)

Sets the request object being wrapped.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

requestback to summary
private ServletRequest request

Constructor Detail

ServletRequestWrapperback to summary
public ServletRequestWrapper(ServletRequest request)

Creates a ServletRequest adaptor wrapping the given request object.

Exceptions
IllegalArgumentException:
if the request is null

Method Detail

getAttributeback to summary
public Object getAttribute(String name)

Implements javax.servlet.ServletRequest.getAttribute.

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

Parameters
name:String

Doc from javax.servlet.ServletRequest.getAttribute.

a String specifying the name of the attribute

Returns:Object

Doc from javax.servlet.ServletRequest.getAttribute.

an Object containing the value of the attribute, or null if the attribute does not exist

getAttributeNamesback to summary
public Enumeration<E> getAttributeNames()

Implements javax.servlet.ServletRequest.getAttributeNames.

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

Returns:Enumeration<E>

Doc from javax.servlet.ServletRequest.getAttributeNames.

an Enumeration of strings containing the names of the request's attributes

getCharacterEncodingback to summary
public String getCharacterEncoding()

Implements javax.servlet.ServletRequest.getCharacterEncoding.

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

Returns:String

Doc from javax.servlet.ServletRequest.getCharacterEncoding.

a String containing the name of the chararacter encoding, or null if the request does not specify a character encoding

getContentLengthback to summary
public int getContentLength()

Implements javax.servlet.ServletRequest.getContentLength.

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

Returns:int

Doc from javax.servlet.ServletRequest.getContentLength.

an integer containing the length of the request body or -1 if the length is not known

getContentTypeback to summary
public String getContentType()

Implements javax.servlet.ServletRequest.getContentType.

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

Returns:String

Doc from javax.servlet.ServletRequest.getContentType.

a String containing the name of the MIME type of the request, or null if the type is not known

getInputStreamback to summary
public ServletInputStream getInputStream() throws IOException

Implements javax.servlet.ServletRequest.getInputStream.

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

Returns:ServletInputStream

Doc from javax.servlet.ServletRequest.getInputStream.

a ServletInputStream object containing the body of the request

Exceptions
IOException:

Doc from javax.servlet.ServletRequest.getInputStream.

if an input or output exception occurred

getLocalAddrback to summary
public String getLocalAddr()

Implements javax.servlet.ServletRequest.getLocalAddr.

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

Returns:String

Doc from javax.servlet.ServletRequest.getLocalAddr.

a String containing the IP address on which the request was received.

Since
Servlet 2.4
getLocaleback to summary
public Locale getLocale()

Implements javax.servlet.ServletRequest.getLocale.

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

Returns:Locale

Doc from javax.servlet.ServletRequest.getLocale.

the preferred Locale for the client

getLocalesback to summary
public Enumeration<E> getLocales()

Implements javax.servlet.ServletRequest.getLocales.

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

Returns:Enumeration<E>

Doc from javax.servlet.ServletRequest.getLocales.

an Enumeration of preferred Locale objects for the client

getLocalNameback to summary
public String getLocalName()

Implements javax.servlet.ServletRequest.getLocalName.

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

Returns:String

Doc from javax.servlet.ServletRequest.getLocalName.

a String containing the host name of the IP on which the request was received.

Since
Servlet 2.4
getLocalPortback to summary
public int getLocalPort()

Implements javax.servlet.ServletRequest.getLocalPort.

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

Returns:int

Doc from javax.servlet.ServletRequest.getLocalPort.

an integer specifying the port number

Since
Servlet 2.4
getParameterback to summary
public String getParameter(String name)

Implements javax.servlet.ServletRequest.getParameter.

The default behavior of this method is to return getParameter(String name) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.getParameter.

a String specifying the name of the parameter

Returns:String

Doc from javax.servlet.ServletRequest.getParameter.

a String representing the single value of the parameter

getParameterMapback to summary
public Map<K, V> getParameterMap()

Implements javax.servlet.ServletRequest.getParameterMap.

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

Returns:Map<K, V>

Doc from javax.servlet.ServletRequest.getParameterMap.

an immutable java.util.Map containing parameter names as keys and parameter values as map values. The keys in the parameter map are of type String. The values in the parameter map are of type String array.

getParameterNamesback to summary
public Enumeration<E> getParameterNames()

Implements javax.servlet.ServletRequest.getParameterNames.

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

Returns:Enumeration<E>

Doc from javax.servlet.ServletRequest.getParameterNames.

an Enumeration of String objects, each String containing the name of a request parameter; or an empty Enumeration if the request has no parameters

getParameterValuesback to summary
public String[] getParameterValues(String name)

Implements javax.servlet.ServletRequest.getParameterValues.

The default behavior of this method is to return getParameterValues(String name) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.getParameterValues.

a String containing the name of the parameter whose value is requested

Returns:String[]

Doc from javax.servlet.ServletRequest.getParameterValues.

an array of String objects containing the parameter's values

getProtocolback to summary
public String getProtocol()

Implements javax.servlet.ServletRequest.getProtocol.

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

Returns:String

Doc from javax.servlet.ServletRequest.getProtocol.

a String containing the protocol name and version number

getReaderback to summary
public BufferedReader getReader() throws IOException

Implements javax.servlet.ServletRequest.getReader.

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

Returns:BufferedReader

Doc from javax.servlet.ServletRequest.getReader.

a BufferedReader containing the body of the request

Exceptions
IOException:

Doc from javax.servlet.ServletRequest.getReader.

if an input or output exception occurred

getRealPathback to summary
public String getRealPath(String path)

Implements javax.servlet.ServletRequest.getRealPath.

The default behavior of this method is to return getRealPath(String path) on the wrapped request object.

getRemoteAddrback to summary
public String getRemoteAddr()

Implements javax.servlet.ServletRequest.getRemoteAddr.

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

Returns:String

Doc from javax.servlet.ServletRequest.getRemoteAddr.

a String containing the IP address of the client that sent the request

getRemoteHostback to summary
public String getRemoteHost()

Implements javax.servlet.ServletRequest.getRemoteHost.

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

Returns:String

Doc from javax.servlet.ServletRequest.getRemoteHost.

a String containing the fully qualified name of the client

getRemotePortback to summary
public int getRemotePort()

Implements javax.servlet.ServletRequest.getRemotePort.

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

Since
Servlet 2.4
getRequestback to summary
public ServletRequest getRequest()

Return the wrapped request object.

getRequestDispatcherback to summary
public RequestDispatcher getRequestDispatcher(String path)

Implements javax.servlet.ServletRequest.getRequestDispatcher.

The default behavior of this method is to return getRequestDispatcher(String path) on the wrapped request object.

Parameters
path:String

Doc from javax.servlet.ServletRequest.getRequestDispatcher.

a String specifying the pathname to the resource. If it is relative, it must be relative against the current servlet.

Returns:RequestDispatcher

Doc from javax.servlet.ServletRequest.getRequestDispatcher.

a RequestDispatcher object that acts as a wrapper for the resource at the specified path, or null if the servlet container cannot return a RequestDispatcher

getSchemeback to summary
public String getScheme()

Implements javax.servlet.ServletRequest.getScheme.

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

Returns:String

Doc from javax.servlet.ServletRequest.getScheme.

a String containing the name of the scheme used to make this request

getServerNameback to summary
public String getServerName()

Implements javax.servlet.ServletRequest.getServerName.

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

Returns:String

Doc from javax.servlet.ServletRequest.getServerName.

a String containing the name of the server

getServerPortback to summary
public int getServerPort()

Implements javax.servlet.ServletRequest.getServerPort.

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

Returns:int

Doc from javax.servlet.ServletRequest.getServerPort.

an integer specifying the port number

isSecureback to summary
public boolean isSecure()

Implements javax.servlet.ServletRequest.isSecure.

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

Returns:boolean

Doc from javax.servlet.ServletRequest.isSecure.

a boolean indicating if the request was made using a secure channel

removeAttributeback to summary
public void removeAttribute(String name)

Implements javax.servlet.ServletRequest.removeAttribute.

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

Parameters
name:String

Doc from javax.servlet.ServletRequest.removeAttribute.

a String specifying the name of the attribute to remove

setAttributeback to summary
public void setAttribute(String name, Object o)

Implements javax.servlet.ServletRequest.setAttribute.

The default behavior of this method is to return setAttribute(String name, Object o) on the wrapped request object.

Parameters
name:String

Doc from javax.servlet.ServletRequest.setAttribute.

a String specifying the name of the attribute

o:Object

Doc from javax.servlet.ServletRequest.setAttribute.

the Object to be stored

setCharacterEncodingback to summary
public void setCharacterEncoding(String enc) throws UnsupportedEncodingException

Implements javax.servlet.ServletRequest.setCharacterEncoding.

The default behavior of this method is to set the character encoding on the wrapped request object.

Parameters
enc:String

Doc from javax.servlet.ServletRequest.setCharacterEncoding.

a String containing the name of the chararacter encoding.

Exceptions
UnsupportedEncodingException:

Doc from javax.servlet.ServletRequest.setCharacterEncoding.

if this is not a valid encoding

setRequestback to summary
public void setRequest(ServletRequest request)

Sets the request object being wrapped.

Exceptions
IllegalArgumentException:
if the request is null.