public class HttpServletRequestWrapper
extends javax.servlet.http.HttpServletRequestWrapper
Modifier and Type | Field and Description |
---|---|
protected javax.servlet.http.HttpServletResponse |
m_res
The app server's response object.
|
Constructor and 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.
|
Modifier and Type | Method and 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 an
Object ,
or null if no attribute of the given name exists. |
Enumeration |
getAttributeNames()
Returns an
Enumeration 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 current
HttpSession associated with this
request or, if there is no current session and fCreate
is true, returns a new session. |
javax.servlet.http.HttpSession |
getSession(boolean fCreate,
boolean fCookie)
Returns the current
HttpSession associated with this
request or, if there is no current session and fCreate
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, use
isRequestedSessionIdFromURL() 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.
|
getAuthType, getContextPath, getCookies, getDateHeader, getHeader, getHeaderNames, getHeaders, getIntHeader, getMethod, getPathInfo, getPathTranslated, getQueryString, getRemoteUser, getRequestURI, getRequestURL, getServletPath, getUserPrincipal, isUserInRole
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequest, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding, setRequest
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getCharacterEncoding, getContentLength, getContentType, getInputStream, getLocalAddr, getLocale, getLocales, getLocalName, getLocalPort, getParameter, getParameterMap, getParameterNames, getParameterValues, getProtocol, getReader, getRealPath, getRemoteAddr, getRemoteHost, getRemotePort, getRequestDispatcher, getScheme, getServerName, getServerPort, isSecure, removeAttribute, setAttribute, setCharacterEncoding
protected javax.servlet.http.HttpServletResponse m_res
public HttpServletRequestWrapper(SessionHelper helper, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res, String sSessionId, boolean fCookie, boolean fUrl)
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 urlpublic Object getAttribute(String sName)
Object
,
or null
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 using
ServletRequest.setAttribute(java.lang.String, java.lang.Object)
. This allows information to be
embedded into a request before a RequestDispatcher
call.
Attribute names should follow the same conventions as package
names. This specification reserves names matching java.*
,
javax.*
, and sun.*
.
getAttribute
in interface javax.servlet.ServletRequest
getAttribute
in class javax.servlet.ServletRequestWrapper
sName
- a String
specifying the name of the
attributeObject
containing the value of the attribute,
or null
if the attribute does not existpublic Enumeration getAttributeNames()
Enumeration
containing the names of the
attributes available to this request. This method returns an empty
Enumeration
if the request has no attributes available
to it.getAttributeNames
in interface javax.servlet.ServletRequest
getAttributeNames
in class javax.servlet.ServletRequestWrapper
Enumeration
of strings containing the names
of the request's attributespublic String getRequestedSessionId()
null
.getRequestedSessionId
in interface javax.servlet.http.HttpServletRequest
getRequestedSessionId
in class javax.servlet.http.HttpServletRequestWrapper
String
specifying the session ID, or
null
if the request did not specify a session IDpublic javax.servlet.http.HttpSession getSession()
getSession
in interface javax.servlet.http.HttpServletRequest
getSession
in class javax.servlet.http.HttpServletRequestWrapper
HttpSession
associated with this requestpublic javax.servlet.http.HttpSession getSession(boolean fCreate)
HttpSession
associated with this
request or, if there is no current session and fCreate
is true, returns a new session.
If fCreate
is false
and the request has no
valid HttpSession
, this method returns null
.
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.
getSession
in interface javax.servlet.http.HttpServletRequest
getSession
in class javax.servlet.http.HttpServletRequestWrapper
fCreate
- true
to create a new session for this
request if necessary; false
to return
null
if there's no current sessionHttpSession
associated with this request or
null
if fCreate
is
false
and the request has no valid sessionpublic javax.servlet.http.HttpSession getSession(boolean fCreate, boolean fCookie)
HttpSession
associated with this
request or, if there is no current session and fCreate
is true, returns a new session.
If fCreate
is false
and the request has no
valid HttpSession
, this method returns null
.
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.
fCreate
- true
to create a new session for this
request if necessary; false
to return
null
if there's no current sessionfCookie
- true
to create a session cookie in
the responseHttpSession
associated with this request or
null
if fCreate
is
false
and the request has no valid sessionpublic boolean isRequestedSessionIdFromCookie()
isRequestedSessionIdFromCookie
in interface javax.servlet.http.HttpServletRequest
isRequestedSessionIdFromCookie
in class javax.servlet.http.HttpServletRequestWrapper
true
if the session ID came in as a cookie;
otherwise, false
public boolean isRequestedSessionIdFromURL()
isRequestedSessionIdFromURL
in interface javax.servlet.http.HttpServletRequest
isRequestedSessionIdFromURL
in class javax.servlet.http.HttpServletRequestWrapper
true
if the session ID came in as part of a URL;
otherwise, false
public boolean isRequestedSessionIdFromUrl()
isRequestedSessionIdFromURL()
instead.isRequestedSessionIdFromUrl
in interface javax.servlet.http.HttpServletRequest
isRequestedSessionIdFromUrl
in class javax.servlet.http.HttpServletRequestWrapper
true
if the session ID came in as part of a URL;
otherwise, false
public boolean isRequestedSessionIdValid()
isRequestedSessionIdValid
in interface javax.servlet.http.HttpServletRequest
isRequestedSessionIdValid
in class javax.servlet.http.HttpServletRequestWrapper
true
if this request has an id for a valid
session in the current session context; false
otherwisepublic String changeSessionId()
public String toString()
protected String getDescription()
public SessionHelper getSessionHelper()
public javax.servlet.http.HttpServletRequest getHttpServletRequest()
public javax.servlet.http.HttpServletResponse getHttpServletResponse()