# com.bea.wlw.netui.pageflow.scoping
ScopedServletUtils Class

public class ScopedServletUtils
extends `Object`

Utilities for creating scoped wrapper versions of HttpRequest, HttpResponse, ServletContext. These wrappers are the basis for a scoped servlet environment, which can be used to scope the Struts framework.

Hierarchy
  `Object`
  `ScopedServletUtils`

## Field Summary

`public static final `String`` | `SCOPE_ID_PARAM` String

## Constructor Summary

ScopedServletUtils()

## Method Summary

`public static `HttpServletRequest`` | `getOuterRequest`(`HttpServletRequest` request) Get the outer (unwrapped) request.
`public static final `String`` | `getRelativeURI`(`HttpServletRequest` request) Get the request URI, relative to the webapp root.
`public static final `String`` | `getRelativeURI`(`HttpServletRequest` request, `String` uri) Get a URI relative to the webapp root.
`public static `String`` | `getScopedName`(`String` baseName, `Object` scopeKey) Get a scoped version of a given name.
`public static `ScopedRequest`` | `getScopedRequest`(`HttpServletRequest` realRequest, `String` overrideURI, `ServletContext` servletContext, `Object` scopeKey) Get the cached wrapper servlet request.
`public static `ScopedResponse`` | `getScopedResponse`(`HttpServletResponse` realResponse, `ScopedRequest` scopedRequest) Get the cached wrapper servlet response.
`public static `ScopedServletContext`` | `getScopedServletContext`(`HttpServletRequest` realRequest, `ServletContext` realServletContext, `Object` scopeKey) Get the cached wrapper servlet context.
`public static `Object`` | `getScopedSessionAttr`(`String` attrName, `HttpServletRequest` request) If the request is a ScopedRequest, this returns an attribute whose name is scoped to that request's scope-ID; otherwise, it is a straight passthrough to `HttpSession.getAttribute(String)```.
`public static `String`` | `getScopedSessionAttrName`(`String` attrName, `HttpServletRequest` request) If the request is a ScopedRequest, this returns an attribute name scoped to that request's scope-ID; otherwise, it returns the given attribute name.
`public static void` | `renameScope`(`Object` oldScopeKey, `Object` newScopeKey, `HttpServletRequest` request) Find all scoped objects (`ScopedRequest```, `ScopedResponse```, `ScopedServletContext```) which have a certain scope-key, replaces this scope-key with the new one, and re-caches the objects the new scope-key.
`public static `ScopedRequest`` | `unwrapRequest`(`ServletRequest` request) Unwraps the contained ScopedRequest from the given ServletRequest, which may be a ServletRequestWrapper.
`public static `ScopedResponse`` | `unwrapResponse`(`ServletResponse` response) Unwraps the contained ScopedResponseImpl from the given ServletResponse, which may be a ServletResponseWrapper.

Methods from class `java.lang.`Object``
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Detail

### SCOPE_ID_PARAM

    public static final String SCOPE_ID_PARAM

## Constructor Detail

### ScopedServletUtils

    public ScopedServletUtils()

## Method Detail

### getOuterRequest(HttpServletRequest) Method

    public static HttpServletRequest getOuterRequest(HttpServletRequest request)

Get the outer (unwrapped) request.

#### Parameters

request
  the request to unwrap.

#### Returns

the outer request, if the given request is a ScopedRequest (or wraps a ScopedRequest); otherwise, the given request itself.

### getRelativeURI(HttpServletRequest) Method

    public static final String getRelativeURI(HttpServletRequest request)

Get the request URI, relative to the webapp root.

#### Parameters

request
  the current HttpServletRequest.

### getRelativeURI(HttpServletRequest, String) Method

    public static final String getRelativeURI(HttpServletRequest request,
                                              String uri)

Get a URI relative to the webapp root.

#### Parameters

request
  the current HttpServletRequest.

uri
  the URI which should be made relative.

### getScopedName(String, Object) Method

    public static String getScopedName(String baseName,
                                       Object scopeKey)

Get a scoped version of a given name.

#### Parameters

baseName
  the name to be scoped.

scopeKey
  the context key for scoping the name.

#### Returns

a scoped version of the given name.

### getScopedRequest(HttpServletRequest, String, ServletContext, Object) Method

    public static ScopedRequest getScopedRequest(HttpServletRequest realRequest,
                                                 String overrideURI,
                                                 ServletContext servletContext,
                                                 Object scopeKey)

Get the cached wrapper servlet request. If none exists, creates one and caches it.

#### Parameters

realRequest
  the "real" (outer) HttpServletRequest, which will be wrapped.

overrideURI
  the request-URI for the wrapped object. This is a webapp-relative URI, i.e., it does not include the context path.

servletContext
  the current ServletContext. May be a `ScopedServletContext```.

#### Returns

the cached (or newly-created) ScopedRequest.

### getScopedResponse(HttpServletResponse, ScopedRequest) Method

    public static ScopedResponse getScopedResponse(HttpServletResponse realResponse,
                                                   ScopedRequest scopedRequest)

Get the cached wrapper servlet response. If none exists, creates one and caches it.

#### Parameters

realResponse
  the "real" (outer) ServletResponse, which will be wrapped.

scopedRequest
  the ScopedRequest returned from `ScopedServletUtils.getScopedRequest(HttpServletRequest, String, ServletContext, Object)```.

#### Returns

the cached (or newly-created) ScopedResponse.

### getScopedServletContext(HttpServletRequest, ServletContext, Object) Method

    public static ScopedServletContext getScopedServletContext(HttpServletRequest realRequest,
                                                               ServletContext realServletContext,
                                                               Object scopeKey)

Get the cached wrapper servlet context. If none exists, creates one and caches it.

#### Parameters

realRequest
  the "real" (outer) request object.

realServletContext
  the "real" (outer) ServletContext, which will be wrapped.

scopeKey
  the context-key with which to scope the wrapper objects.

#### Returns

the cached (or newly-created) ScopedContext.

### getScopedSessionAttr(String, HttpServletRequest) Method

    public static Object getScopedSessionAttr(String attrName,
                                              HttpServletRequest request)

If the request is a ScopedRequest, this returns an attribute whose name is scoped to that request's scope-ID; otherwise, it is a straight passthrough to `HttpSession.getAttribute(String)```.

### getScopedSessionAttrName(String, HttpServletRequest) Method

    public static String getScopedSessionAttrName(String attrName,
                                                  HttpServletRequest request)

If the request is a ScopedRequest, this returns an attribute name scoped to that request's scope-ID; otherwise, it returns the given attribute name.

### renameScope(Object, Object, HttpServletRequest) Method

    public static void renameScope(Object oldScopeKey,
                                   Object newScopeKey,
                                   HttpServletRequest request)

Find all scoped objects (`ScopedRequest```, `ScopedResponse```, `ScopedServletContext```) which have a certain scope-key, replaces this scope-key with the new one, and re-caches the objects the new scope-key.

### unwrapRequest(ServletRequest) Method

    public static ScopedRequest unwrapRequest(ServletRequest request)

Unwraps the contained ScopedRequest from the given ServletRequest, which may be a ServletRequestWrapper.

#### Parameters

request
  the ScopedRequest, or a wrapper (ServletRequestWrapper) around it.

#### Returns

the unwrapped ScopedRequest.

### unwrapResponse(ServletResponse) Method

    public static ScopedResponse unwrapResponse(ServletResponse response)

Unwraps the contained ScopedResponseImpl from the given ServletResponse, which may be a ServletResponseWrapper.

#### Parameters

response
  the ScopedResponse, or a wrapper (ServletResponseWrapper) around it.

#### Returns

the unwrapped ScopedResponseImpl.