CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation

com.tangosol.coherence.servlet
Class HttpRequestContext

java.lang.Object
  extended by com.tangosol.util.Base
      extended by com.tangosol.coherence.servlet.RequestContext
          extended by com.tangosol.coherence.servlet.HttpRequestContext

public class HttpRequestContext
extends RequestContext

Request context information for an HTTP Servlet request.

Version:
Coherence 2.3
Author:
cp 2003.09.13

Field Summary
protected static String KEY_SESSION_ID
          The key used to store the current session ID in the map returned by saveRequestState.
 
Fields inherited from class com.tangosol.coherence.servlet.RequestContext
KEY_REQUEST, KEY_RESPONSE, REQ_ATTR_CONTEXT, REQ_ATTR_DISPATCH, REQ_ATTR_OK_WRAP, REQ_ATTR_REQUEST, REQ_ATTR_WRAPPED
 
Constructor Summary
HttpRequestContext(SessionHelper helper, RequestContext ctxOuter, HttpServletRequest req, String sSessionId, boolean fCookie, boolean fUrl)
          Construct a HttpRequestContext object to hold the state of the request and response and the wrappers for each.
 
Method Summary
protected  String getDescription()
          Returns a string representation of this object's attributes.
 HttpServletRequest getHttpServletRequest()
          Get the wrapped HttpServletRequest.
 HttpServletRequest getHttpServletRequestWrapper()
          Get the HttpServletRequest wrapper.
 HttpServletResponse getHttpServletResponse()
          Get the wrapped HttpServletResponse.
 HttpServletResponse getHttpServletResponseWrapper()
          Get the HttpServletResponse wrapper.
 HttpRequestContext getOuterHttpRequestContext()
          Determine the HttpRequestContext object that this HttpRequestContext exists "within", if this request context was created by a nested request, such as by including or forwarding.
 HttpSession getSession()
          Returns the current session associated with the stack of request context objects, or if the session has not been associated yet with the stack of request context objects, returns null.
 String getSessionId()
          Determine the HTTP session ID that came in with the request.
 boolean isRequestedSessionIdFromCookie()
          Checks whether the requested session ID came in as a cookie.
 boolean isRequestedSessionIdFromURL()
          Checks whether the requested session ID came in as part of the request URL.
 void restoreRequestState(Map mapState, boolean fExternal)
          Restores the underlying Servlet request back to the state it was in prior to calling saveRequestState.
 Map saveRequestState(boolean fExternal)
          Returns a map containing the state of the underlying Servlet request.
 void setSession(HttpSession session)
          Store the current session to be associated with the stack of request context objects, or if no session should be associated with the stack of request context objects.
protected  void setSessionId(String sSessionId)
          Sets the ID of the session associated with the request.
 String toString()
          Returns a string representation of the object.
 
Methods inherited from class com.tangosol.coherence.servlet.RequestContext
decReferenceCount, getOuterRequestContext, getReferenceCount, getServletRequest, getServletRequestWrapper, getServletResponse, getServletResponseWrapper, getSessionHelper, incReferenceCount, isNested, setServletRequestWrapper, setServletResponse, setServletResponseWrapper
 

Field Detail

KEY_SESSION_ID

protected static final String KEY_SESSION_ID
The key used to store the current session ID in the map returned by saveRequestState.

See Also:
Constant Field Values
Constructor Detail

HttpRequestContext

public HttpRequestContext(SessionHelper helper,
                          RequestContext ctxOuter,
                          HttpServletRequest req,
                          String sSessionId,
                          boolean fCookie,
                          boolean fUrl)
Construct a HttpRequestContext object to hold the state of the request and response and the wrappers for each.

Parameters:
helper - the SessionHelper for this application
ctxOuter - the outer RequestContext object, or null if none
req - the application server's HttpServletRequest object
sSessionId - the session id (if any) that came with the request
fCookie - if the session id came from a cookie
fUrl - if the session id came from the url
Method Detail

saveRequestState

public Map saveRequestState(boolean fExternal)
Returns a map containing the state of the underlying Servlet request. This method should be called prior to creating a nested request, such as when including or forwarding. The request can be restored to the state it was in at the time this method was called by calling restoreRequestState with the map returned from this method.

If the fExternal parameter is true, any outstanding session state changes are flushed to the cluster and ownership of the session is relinquished.

Overrides:
saveRequestState in class RequestContext
Parameters:
fExternal - true if the nested request will target an external web application
Returns:
a map containing the state of the underlying Servlet request

restoreRequestState

public void restoreRequestState(Map mapState,
                                boolean fExternal)
Restores the underlying Servlet request back to the state it was in prior to calling saveRequestState.

If the fExternal parameter is true, ownership of the current session (if any) is reestablished.

Overrides:
restoreRequestState in class RequestContext
Parameters:
mapState - the Map returned from a call to saveRequestState
fExternal - true if the nested request had targeted an external web application

getOuterHttpRequestContext

public HttpRequestContext getOuterHttpRequestContext()
Determine the HttpRequestContext object that this HttpRequestContext exists "within", if this request context was created by a nested request, such as by including or forwarding.

Returns:
the HttpRequestContext object that this RequestContext exists "within"

getHttpServletRequest

public HttpServletRequest getHttpServletRequest()
Get the wrapped HttpServletRequest.

Returns:
the wrapped HttpServletRequest

getHttpServletResponse

public HttpServletResponse getHttpServletResponse()
Get the wrapped HttpServletResponse.

Returns:
the wrapped HttpServletResponse

getHttpServletRequestWrapper

public HttpServletRequest getHttpServletRequestWrapper()
Get the HttpServletRequest wrapper.

Returns:
the HttpServletRequest wrapper, or null if it has not yet been created

getHttpServletResponseWrapper

public HttpServletResponse getHttpServletResponseWrapper()
Get the HttpServletResponse wrapper.

Returns:
the HttpServletResponse wrapper, or null if it has not yet been created

getSessionId

public String getSessionId()
Determine the HTTP session ID that came in with the request.

Returns:
the HTTP session ID that came in with the request; may be null

setSessionId

protected void setSessionId(String sSessionId)
Sets the ID of the session associated with the request.

Parameters:
sSessionId - the new session ID

isRequestedSessionIdFromCookie

public boolean isRequestedSessionIdFromCookie()
Checks whether the requested session ID came in as a cookie.

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.

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

getSession

public HttpSession getSession()
Returns the current session associated with the stack of request context objects, or if the session has not been associated yet with the stack of request context objects, returns null.

Returns:
the HttpSession object that has been associated with the stack of request context objects

setSession

public void setSession(HttpSession session)
Store the current session to be associated with the stack of request context objects, or if no session should be associated with the stack of request context objects.

Parameters:
session - the HttpSession object to associated with the stack of request context objects

toString

public String toString()
Returns a string representation of the object.

Overrides:
toString in class RequestContext
Returns:
a string representation of the object

getDescription

protected String getDescription()
Returns a string representation of this object's attributes.

Overrides:
getDescription in class RequestContext
Returns:
a string representation of this object's attributes

CoherenceTM v3.3
Copyright© 2000-2007 by Oracle Corporation