Class HttpServletRequestWrapper
- All Implemented Interfaces:
javax.servlet.http.HttpServletRequest,javax.servlet.ServletRequest
- Version:
- Coherence 2.3
- Author:
- cp 2003.07.24
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected javax.servlet.http.HttpServletResponseThe app server's response object.Fields inherited from interface javax.servlet.http.HttpServletRequest
BASIC_AUTH, CLIENT_CERT_AUTH, DIGEST_AUTH, FORM_AUTH -
Constructor Summary
ConstructorsConstructorDescriptionHttpServletRequestWrapper(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
Modifier and TypeMethodDescriptionChange the session id of the current session associated with this request and return the new session ID.getAttribute(String sName) Returns the value of the named attribute as anObject, ornullif no attribute of the given name exists.Returns anEnumerationcontaining the names of the attributes available to this request.protected StringReturns a string representation of this object's attributes.javax.servlet.http.HttpServletRequestGet the wrapped HttpServletRequest.javax.servlet.http.HttpServletResponseGet the HttpServletResponse associated with the wrapped HttpServletRequest.Returns the session ID specified by the client.javax.servlet.http.HttpSessionReturns the current session associated with this request, or if the request does not have a session, creates one.javax.servlet.http.HttpSessiongetSession(boolean fCreate) Returns the currentHttpSessionassociated with this request or, if there is no current session andfCreateis true, returns a new session.javax.servlet.http.HttpSessiongetSession(boolean fCreate, boolean fCookie) Returns the currentHttpSessionassociated with this request or, if there is no current session andfCreateis true, returns a new session.Get the SessionHelper.booleanChecks whether the requested session ID came in as a cookie.booleanDeprecated.booleanChecks whether the requested session ID came in as part of the request URL.booleanChecks whether the requested session ID is still valid.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, upgradeMethods 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, startAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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
-
Field Details
-
m_res
protected javax.servlet.http.HttpServletResponse m_resThe app server's response object.
-
-
Constructor Details
-
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 Details
-
getAttribute
Returns the value of the named attribute as anObject, ornullif 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.X509Certificatecan 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 aRequestDispatchercall.Attribute names should follow the same conventions as package names. This specification reserves names matching
java.*,javax.*, andsun.*.- Specified by:
getAttributein interfacejavax.servlet.ServletRequest- Overrides:
getAttributein classjavax.servlet.ServletRequestWrapper- Parameters:
sName- aStringspecifying the name of the attribute- Returns:
- an
Objectcontaining the value of the attribute, ornullif the attribute does not exist
-
getAttributeNames
Returns anEnumerationcontaining the names of the attributes available to this request. This method returns an emptyEnumerationif the request has no attributes available to it.- Specified by:
getAttributeNamesin interfacejavax.servlet.ServletRequest- Overrides:
getAttributeNamesin classjavax.servlet.ServletRequestWrapper- Returns:
- an
Enumerationof strings containing the names of the request's attributes
-
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:
getRequestedSessionIdin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getRequestedSessionIdin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
- a
Stringspecifying the session ID, ornullif 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:
getSessionin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getSessionin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
- the
HttpSessionassociated with this request
-
getSession
public javax.servlet.http.HttpSession getSession(boolean fCreate) Returns the currentHttpSessionassociated with this request or, if there is no current session andfCreateis true, returns a new session.If
fCreateisfalseand 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:
getSessionin interfacejavax.servlet.http.HttpServletRequest- Overrides:
getSessionin classjavax.servlet.http.HttpServletRequestWrapper- Parameters:
fCreate-trueto create a new session for this request if necessary;falseto returnnullif there's no current session- Returns:
- the
HttpSessionassociated with this request ornulliffCreateisfalseand the request has no valid session
-
getSession
public javax.servlet.http.HttpSession getSession(boolean fCreate, boolean fCookie) Returns the currentHttpSessionassociated with this request or, if there is no current session andfCreateis true, returns a new session.If
fCreateisfalseand 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-trueto create a new session for this request if necessary;falseto returnnullif there's no current sessionfCookie-trueto create a session cookie in the response- Returns:
- the
HttpSessionassociated with this request ornulliffCreateisfalseand the request has no valid session
-
isRequestedSessionIdFromCookie
public boolean isRequestedSessionIdFromCookie()Checks whether the requested session ID came in as a cookie.- Specified by:
isRequestedSessionIdFromCookiein interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdFromCookiein classjavax.servlet.http.HttpServletRequestWrapper- Returns:
trueif 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:
isRequestedSessionIdFromURLin interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdFromURLin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
trueif 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:
isRequestedSessionIdFromUrlin interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdFromUrlin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
trueif 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:
isRequestedSessionIdValidin interfacejavax.servlet.http.HttpServletRequest- Overrides:
isRequestedSessionIdValidin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
trueif this request has an id for a valid session in the current session context;falseotherwise
-
changeSessionId
Change the session id of the current session associated with this request and return the new session ID.- Specified by:
changeSessionIdin interfacejavax.servlet.http.HttpServletRequest- Overrides:
changeSessionIdin classjavax.servlet.http.HttpServletRequestWrapper- Returns:
- the new session ID
-
toString
Returns a string representation of the object. -
getDescription
Returns a string representation of this object's attributes.- Returns:
- a string representation of this object's attributes
-
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
-
isRequestedSessionIdFromURL()instead.