Class HttpServletRequestWrapper
- java.lang.Object
-
- javax.servlet.ServletRequestWrapper
-
- javax.servlet.http.HttpServletRequestWrapper
-
- com.tangosol.coherence.servlet.api23.HttpServletRequestWrapper
-
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest
,javax.servlet.ServletRequest
public class HttpServletRequestWrapper extends javax.servlet.http.HttpServletRequestWrapper
An HttpServletRequest wrapper.- Version:
- Coherence 2.3
- Author:
- cp 2003.07.24
-
-
Field Summary
Fields Modifier and Type Field Description protected javax.servlet.http.HttpServletResponse
m_res
The app server's response object.
-
Constructor Summary
Constructors Constructor Description HttpServletRequestWrapper(SessionHelper helper, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String sSessionId, boolean fCookie, boolean fUrl)
Construct an HttpServletRequestWrapper object to wrap an app server's request object.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description String
changeSessionId()
Change the session id of the current session associated with this request and return the new session ID.Object
getAttribute(String sName)
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists.Enumeration
getAttributeNames()
Returns anEnumeration
containing the names of the attributes available to this request.protected String
getDescription()
Returns a string representation of this object's attributes.javax.servlet.http.HttpServletRequest
getHttpServletRequest()
Get the wrapped HttpServletRequest.javax.servlet.http.HttpServletResponse
getHttpServletResponse()
Get the HttpServletResponse associated with the wrapped HttpServletRequest.String
getRequestedSessionId()
Returns the session ID specified by the client.javax.servlet.http.HttpSession
getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one.javax.servlet.http.HttpSession
getSession(boolean fCreate)
Returns the currentHttpSession
associated with this request or, if there is no current session andfCreate
is true, returns a new session.javax.servlet.http.HttpSession
getSession(boolean fCreate, boolean fCookie)
Returns the currentHttpSession
associated with this request or, if there is no current session andfCreate
is true, returns a new session.SessionHelper
getSessionHelper()
Get the SessionHelper.boolean
isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.boolean
isRequestedSessionIdFromUrl()
Deprecated.As of Version 2.1 of the Java Servlet API, useisRequestedSessionIdFromURL()
instead.boolean
isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL.boolean
isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.String
toString()
Returns a string representation of the object.-
Methods inherited from class javax.servlet.http.HttpServletRequestWrapper
authenticate, getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getHttpServletMapping, getIntHeader, getMethod, getPart, getParts, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestURI, getRequestURL, getServletPath, getTrailerFields, getUserPrincipal, isTrailerFieldsReady, isUserInRole, login, logout, newPushBuilder, upgrade
-
Methods inherited from class javax.servlet.ServletRequestWrapper
getAsyncContext, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, isWrapperFor, isWrapperFor, removeAttribute, setAttribute, setCharacterEncoding, setRequest, startAsync, startAsync
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface javax.servlet.ServletRequest
getAsyncContext, getCharacterEncoding, getContentLength, getContentLengthLong, getContentType, getDispatcherType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, getServletContext, isAsyncStarted, isAsyncSupported, isSecure, removeAttribute, setAttribute, setCharacterEncoding, startAsync, startAsync
-
-
-
-
Constructor Detail
-
HttpServletRequestWrapper
public HttpServletRequestWrapper(SessionHelper helper, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String sSessionId, boolean fCookie, boolean fUrl)
Construct an HttpServletRequestWrapper object to wrap an app server's request object.- Parameters:
helper
- the SessionHelper for this applicationreq
- the app server's request objectres
- the app server's response objectsSessionId
- the session ID (if any) that came with the requestfCookie
- if the session ID came from a cookiefUrl
- if the session ID came from the url
-
-
Method Detail
-
getAttribute
public Object getAttribute(String sName)
Returns the value of the named attribute as anObject
, ornull
if no attribute of the given name exists.Attributes can be set two ways. The servlet container may set attributes to make available custom information about a request. For example, for requests made using HTTPS, the attribute
javax.servlet.request.X509Certificate
can be used to retrieve information on the certificate of the client. Attributes can also be set programatically usingServletRequest.setAttribute(java.lang.String, java.lang.Object)
. This allows information to be embedded into a request before aRequestDispatcher
call.Attribute names should follow the same conventions as package names. This specification reserves names matching
java.*
,javax.*
, andsun.*
.- Specified by:
getAttribute
in interfacejavax.servlet.ServletRequest
- Overrides:
getAttribute
in classjavax.servlet.ServletRequestWrapper
- Parameters:
sName
- aString
specifying the name of the attribute- Returns:
- an
Object
containing the value of the attribute, ornull
if the attribute does not exist
-
getAttributeNames
public Enumeration getAttributeNames()
Returns anEnumeration
containing the names of the attributes available to this request. This method returns an emptyEnumeration
if the request has no attributes available to it.- Specified by:
getAttributeNames
in interfacejavax.servlet.ServletRequest
- Overrides:
getAttributeNames
in classjavax.servlet.ServletRequestWrapper
- Returns:
- an
Enumeration
of strings containing the names of the request's attributes
-
getRequestedSessionId
public String getRequestedSessionId()
Returns the session ID specified by the client. This may not be the same as the ID of the actual session in use. For example, if the request specified an old (expired) session ID and the server has started a new session, this method gets a new session with a new ID. If the request did not specify a session ID, this method returnsnull
.- Specified by:
getRequestedSessionId
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
getRequestedSessionId
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
- a
String
specifying the session ID, ornull
if the request did not specify a session ID
-
getSession
public javax.servlet.http.HttpSession getSession()
Returns the current session associated with this request, or if the request does not have a session, creates one.- Specified by:
getSession
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
getSession
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
- the
HttpSession
associated with this request
-
getSession
public javax.servlet.http.HttpSession getSession(boolean fCreate)
Returns the currentHttpSession
associated with this request or, if there is no current session andfCreate
is true, returns a new session.If
fCreate
isfalse
and the request has no validHttpSession
, this method returnsnull
.To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
- Specified by:
getSession
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
getSession
in classjavax.servlet.http.HttpServletRequestWrapper
- Parameters:
fCreate
-true
to create a new session for this request if necessary;false
to returnnull
if there's no current session- Returns:
- the
HttpSession
associated with this request ornull
iffCreate
isfalse
and the request has no valid session
-
getSession
public javax.servlet.http.HttpSession getSession(boolean fCreate, boolean fCookie)
Returns the currentHttpSession
associated with this request or, if there is no current session andfCreate
is true, returns a new session.If
fCreate
isfalse
and the request has no validHttpSession
, this method returnsnull
.To make sure the session is properly maintained, you must call this method before the response is committed. If the container is using cookies to maintain session integrity and is asked to create a new session when the response is committed, an IllegalStateException is thrown.
- Parameters:
fCreate
-true
to create a new session for this request if necessary;false
to returnnull
if there's no current sessionfCookie
-true
to create a session cookie in the response- Returns:
- the
HttpSession
associated with this request ornull
iffCreate
isfalse
and the request has no valid session
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.- Specified by:
isRequestedSessionIdFromCookie
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
isRequestedSessionIdFromCookie
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
true
if the session ID came in as a cookie; otherwise,false
-
isRequestedSessionIdFromURL
public boolean isRequestedSessionIdFromURL()
Checks whether the requested session ID came in as part of the request URL.- Specified by:
isRequestedSessionIdFromURL
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
isRequestedSessionIdFromURL
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
true
if the session ID came in as part of a URL; otherwise,false
-
isRequestedSessionIdFromUrl
public boolean isRequestedSessionIdFromUrl()
Deprecated.As of Version 2.1 of the Java Servlet API, useisRequestedSessionIdFromURL()
instead.Checks whether the requested session ID came in as part of the request URL.- Specified by:
isRequestedSessionIdFromUrl
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
isRequestedSessionIdFromUrl
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
true
if the session ID came in as part of a URL; otherwise,false
-
isRequestedSessionIdValid
public boolean isRequestedSessionIdValid()
Checks whether the requested session ID is still valid.- Specified by:
isRequestedSessionIdValid
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
isRequestedSessionIdValid
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
true
if this request has an id for a valid session in the current session context;false
otherwise
-
changeSessionId
public String changeSessionId()
Change the session id of the current session associated with this request and return the new session ID.- Specified by:
changeSessionId
in interfacejavax.servlet.http.HttpServletRequest
- Overrides:
changeSessionId
in classjavax.servlet.http.HttpServletRequestWrapper
- Returns:
- the new session ID
-
toString
public String toString()
Returns a string representation of the object.
-
getDescription
protected String getDescription()
Returns a string representation of this object's attributes.- Returns:
- a string representation of this object's attributes
-
getSessionHelper
public SessionHelper getSessionHelper()
Get the SessionHelper.- Returns:
- the SessionHelper for this app
-
getHttpServletRequest
public javax.servlet.http.HttpServletRequest getHttpServletRequest()
Get the wrapped HttpServletRequest.- Returns:
- the wrapped HttpServletRequest
-
getHttpServletResponse
public javax.servlet.http.HttpServletResponse getHttpServletResponse()
Get the HttpServletResponse associated with the wrapped HttpServletRequest.- Returns:
- the associated HttpServletResponse
-
-