Top Description Constructors Methods
javax.servlet.http

public Class HttpServletRequestWrapper

extends ServletRequestWrapper
implements HttpServletRequest
Class Inheritance
All Implemented Interfaces
javax.servlet.http.HttpServletRequest, javax.servlet.ServletRequest
Imports
java.util.Enumeration, javax.servlet.ServletRequestWrapper

Provides a convenient implementation of the HttpServletRequest 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
javax.servlet.http.HttpServletRequest

Constructor Summary

AccessConstructor and Description
public
HttpServletRequestWrapper(HttpServletRequest request)

Constructs a request object wrapping the given request.

Method Summary

Modifier and TypeMethod and Description
private HttpServletRequest
public String
getAuthType()

Implements javax.servlet.http.HttpServletRequest.getAuthType.

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

Implements javax.servlet.http.HttpServletRequest.getContextPath.

The default behavior of this method is to return getContextPath() on the wrapped request object.
public Cookie[]
getCookies()

Implements javax.servlet.http.HttpServletRequest.getCookies.

The default behavior of this method is to return getCookies() on the wrapped request object.
public long
getDateHeader(String
a String specifying the name of the header
name
)

Implements javax.servlet.http.HttpServletRequest.getDateHeader.

The default behavior of this method is to return getDateHeader(String name) on the wrapped request object.
public String
getHeader(String
a String specifying the header name
name
)

Implements javax.servlet.http.HttpServletRequest.getHeader.

The default behavior of this method is to return getHeader(String name) on the wrapped request object.
public Enumeration<E>
getHeaderNames()

Implements javax.servlet.http.HttpServletRequest.getHeaderNames.

The default behavior of this method is to return getHeaderNames() on the wrapped request object.
public Enumeration<E>
getHeaders(String
a String specifying the header name
name
)

Implements javax.servlet.http.HttpServletRequest.getHeaders.

The default behavior of this method is to return getHeaders(String name) on the wrapped request object.
public int
getIntHeader(String
a String specifying the name of a request header
name
)

Implements javax.servlet.http.HttpServletRequest.getIntHeader.

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

Implements javax.servlet.http.HttpServletRequest.getMethod.

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

Implements javax.servlet.http.HttpServletRequest.getPathInfo.

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

Implements javax.servlet.http.HttpServletRequest.getPathTranslated.

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

Implements javax.servlet.http.HttpServletRequest.getQueryString.

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

Implements javax.servlet.http.HttpServletRequest.getRemoteUser.

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

Implements javax.servlet.http.HttpServletRequest.getRequestedSessionId.

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

Implements javax.servlet.http.HttpServletRequest.getRequestURI.

The default behavior of this method is to return getRequestURI() on the wrapped request object.
public StringBuffer
getRequestURL()

Implements javax.servlet.http.HttpServletRequest.getRequestURL.

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

Implements javax.servlet.http.HttpServletRequest.getServletPath.

The default behavior of this method is to return getServletPath() on the wrapped request object.
public HttpSession
getSession(boolean
true to create a new session for this request if necessary; false to return null if there's no current session
create
)

Implements javax.servlet.http.HttpServletRequest.getSession.

The default behavior of this method is to return getSession(boolean create) on the wrapped request object.
public HttpSession
getSession()

Implements javax.servlet.http.HttpServletRequest.getSession.

The default behavior of this method is to return getSession() on the wrapped request object.
public Principal
getUserPrincipal()

Implements javax.servlet.http.HttpServletRequest.getUserPrincipal.

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

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromCookie.

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

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromURL.

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

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromUrl.

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

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdValid.

The default behavior of this method is to return isRequestedSessionIdValid() on the wrapped request object.
public boolean
isUserInRole(String
a String specifying the name of the role
role
)

Implements javax.servlet.http.HttpServletRequest.isUserInRole.

The default behavior of this method is to return isUserInRole(String role) on the wrapped request object.
Inherited from javax.servlet.ServletRequestWrapper:
getAttributegetAttributeNamesgetCharacterEncodinggetContentLengthgetContentTypegetInputStreamgetLocalAddrgetLocalegetLocalesgetLocalNamegetLocalPortgetParametergetParameterMapgetParameterNamesgetParameterValuesgetProtocolgetReadergetRealPathgetRemoteAddrgetRemoteHostgetRemotePortgetRequestgetRequestDispatchergetSchemegetServerNamegetServerPortisSecureremoveAttributesetAttributesetCharacterEncodingsetRequest

Constructor Detail

HttpServletRequestWrapperback to summary
public HttpServletRequestWrapper(HttpServletRequest request)

Constructs a request object wrapping the given request.

Exceptions
IllegalArgumentException:
if the request is null

Method Detail

_getHttpServletRequestback to summary
private HttpServletRequest _getHttpServletRequest()
getAuthTypeback to summary
public String getAuthType()

Implements javax.servlet.http.HttpServletRequest.getAuthType.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getAuthType.

one of the static members BASIC_AUTH, FORM_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH (suitable for == comparison) or the container-specific string indicating the authentication scheme, or null if the request was not authenticated.

getContextPathback to summary
public String getContextPath()

Implements javax.servlet.http.HttpServletRequest.getContextPath.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getContextPath.

a String specifying the portion of the request URI that indicates the context of the request

getCookiesback to summary
public Cookie[] getCookies()

Implements javax.servlet.http.HttpServletRequest.getCookies.

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

Returns:Cookie[]

Doc from javax.servlet.http.HttpServletRequest.getCookies.

an array of all the Cookies included with this request, or null if the request has no cookies

getDateHeaderback to summary
public long getDateHeader(String name)

Implements javax.servlet.http.HttpServletRequest.getDateHeader.

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

Parameters
name:String

Doc from javax.servlet.http.HttpServletRequest.getDateHeader.

a String specifying the name of the header

Returns:long

Doc from javax.servlet.http.HttpServletRequest.getDateHeader.

a long value representing the date specified in the header expressed as the number of milliseconds since January 1, 1970 GMT, or -1 if the named header was not included with the reqest

getHeaderback to summary
public String getHeader(String name)

Implements javax.servlet.http.HttpServletRequest.getHeader.

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

Parameters
name:String

Doc from javax.servlet.http.HttpServletRequest.getHeader.

a String specifying the header name

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getHeader.

a String containing the value of the requested header, or null if the request does not have a header of that name

getHeaderNamesback to summary
public Enumeration<E> getHeaderNames()

Implements javax.servlet.http.HttpServletRequest.getHeaderNames.

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

Returns:Enumeration<E>

Doc from javax.servlet.http.HttpServletRequest.getHeaderNames.

an enumeration of all the header names sent with this request; if the request has no headers, an empty enumeration; if the servlet container does not allow servlets to use this method, null

getHeadersback to summary
public Enumeration<E> getHeaders(String name)

Implements javax.servlet.http.HttpServletRequest.getHeaders.

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

Parameters
name:String

Doc from javax.servlet.http.HttpServletRequest.getHeaders.

a String specifying the header name

Returns:Enumeration<E>

Doc from javax.servlet.http.HttpServletRequest.getHeaders.

an Enumeration containing the values of the requested header. If the request does not have any headers of that name return an empty enumeration. If the container does not allow access to header information, return null

getIntHeaderback to summary
public int getIntHeader(String name)

Implements javax.servlet.http.HttpServletRequest.getIntHeader.

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

Parameters
name:String

Doc from javax.servlet.http.HttpServletRequest.getIntHeader.

a String specifying the name of a request header

Returns:int

Doc from javax.servlet.http.HttpServletRequest.getIntHeader.

an integer expressing the value of the request header or -1 if the request doesn't have a header of this name

getMethodback to summary
public String getMethod()

Implements javax.servlet.http.HttpServletRequest.getMethod.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getMethod.

a String specifying the name of the method with which this request was made

getPathInfoback to summary
public String getPathInfo()

Implements javax.servlet.http.HttpServletRequest.getPathInfo.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getPathInfo.

a String, decoded by the web container, specifying extra path information that comes after the servlet path but before the query string in the request URL; or null if the URL does not have any extra path information

getPathTranslatedback to summary
public String getPathTranslated()

Implements javax.servlet.http.HttpServletRequest.getPathTranslated.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getPathTranslated.

a String specifying the real path, or null if the URL does not have any extra path information

getQueryStringback to summary
public String getQueryString()

Implements javax.servlet.http.HttpServletRequest.getQueryString.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getQueryString.

a String containing the query string or null if the URL contains no query string. The value is not decoded by the container.

getRemoteUserback to summary
public String getRemoteUser()

Implements javax.servlet.http.HttpServletRequest.getRemoteUser.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getRemoteUser.

a String specifying the login of the user making this request, or null if the user login is not known

getRequestedSessionIdback to summary
public String getRequestedSessionId()

Implements javax.servlet.http.HttpServletRequest.getRequestedSessionId.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getRequestedSessionId.

a String specifying the session ID, or null if the request did not specify a session ID

getRequestURIback to summary
public String getRequestURI()

Implements javax.servlet.http.HttpServletRequest.getRequestURI.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getRequestURI.

a String containing the part of the URL from the protocol name up to the query string

getRequestURLback to summary
public StringBuffer getRequestURL()

Implements javax.servlet.http.HttpServletRequest.getRequestURL.

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

Returns:StringBuffer

Doc from javax.servlet.http.HttpServletRequest.getRequestURL.

a StringBuffer object containing the reconstructed URL

getServletPathback to summary
public String getServletPath()

Implements javax.servlet.http.HttpServletRequest.getServletPath.

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

Returns:String

Doc from javax.servlet.http.HttpServletRequest.getServletPath.

a String containing the name or path of the servlet being called, as specified in the request URL, decoded, or an empty string if the servlet used to process the request is matched using the "/*" pattern.

getSessionback to summary
public HttpSession getSession(boolean create)

Implements javax.servlet.http.HttpServletRequest.getSession.

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

Parameters
create:boolean

Doc from javax.servlet.http.HttpServletRequest.getSession.

true to create a new session for this request if necessary; false to return null if there's no current session

Returns:HttpSession

Doc from javax.servlet.http.HttpServletRequest.getSession.

the HttpSession associated with this request or null if create is false and the request has no valid session

getSessionback to summary
public HttpSession getSession()

Implements javax.servlet.http.HttpServletRequest.getSession.

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

Returns:HttpSession

Doc from javax.servlet.http.HttpServletRequest.getSession.

the HttpSession associated with this request

getUserPrincipalback to summary
public Principal getUserPrincipal()

Implements javax.servlet.http.HttpServletRequest.getUserPrincipal.

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

Returns:Principal

Doc from javax.servlet.http.HttpServletRequest.getUserPrincipal.

a java.security.Principal containing the name of the user making this request; null if the user has not been authenticated

isRequestedSessionIdFromCookieback to summary
public boolean isRequestedSessionIdFromCookie()

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromCookie.

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

Returns:boolean

Doc from javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromCookie.

true if the session ID came in as a cookie; otherwise, false

isRequestedSessionIdFromURLback to summary
public boolean isRequestedSessionIdFromURL()

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromURL.

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

Returns:boolean

Doc from javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromURL.

true if the session ID came in as part of a URL; otherwise, false

isRequestedSessionIdFromUrlback to summary
public boolean isRequestedSessionIdFromUrl()

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdFromUrl.

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

isRequestedSessionIdValidback to summary
public boolean isRequestedSessionIdValid()

Implements javax.servlet.http.HttpServletRequest.isRequestedSessionIdValid.

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

Returns:boolean

Doc from javax.servlet.http.HttpServletRequest.isRequestedSessionIdValid.

true if this request has an id for a valid session in the current session context; false otherwise

isUserInRoleback to summary
public boolean isUserInRole(String role)

Implements javax.servlet.http.HttpServletRequest.isUserInRole.

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

Parameters
role:String

Doc from javax.servlet.http.HttpServletRequest.isUserInRole.

a String specifying the name of the role

Returns:boolean

Doc from javax.servlet.http.HttpServletRequest.isUserInRole.

a boolean indicating whether the user making this request belongs to a given role; false if the user has not been authenticated