Package net.shibboleth.shared.servlet.impl

# Class HttpServletRequestResponseContext

java.lang.Object
net.shibboleth.shared.servlet.impl.HttpServletRequestResponseContext

public final class HttpServletRequestResponseContext extends Object
Class which holds and makes available the current HTTP servlet request and response via ThreadLocal storage.

See also net.shibboleth.shared.spring.servlet.impl.RequestResponseContextFilter, a Java Servlet `Filter`-based way to populate and clean up this context in a servlet container.

## Field Summary

Fields
Modifier and Type
Field
Description
`private static final ThreadLocal<HttpServletRequest>`
`CURRENT_REQUEST`
ThreadLocal storage for request.
`private static final ThreadLocal<HttpServletResponse>`
`CURRENT_RESPONSE`
ThreadLocal storage for response.

## Constructor Summary

Constructors
Modifier
Constructor
Description
`private`
`HttpServletRequestResponseContext()`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`static void`
`clearCurrent()`
Clear the current thread-local context instances.
`static HttpServletRequest`
`getRequest()`
Get the current `HttpServletRequest` being serviced by the current thread.
`static HttpServletResponse`
`getResponse()`
Get the current `HttpServletResponse` being serviced by the current thread.
`static void`
`loadCurrent(HttpServletRequest request, HttpServletResponse response)`
Load the thread-local storage with the current request and response.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### CURRENT_REQUEST

@Nonnull private static final ThreadLocal<HttpServletRequest> CURRENT_REQUEST
ThreadLocal storage for request.

### CURRENT_RESPONSE

@Nonnull private static final ThreadLocal<HttpServletResponse> CURRENT_RESPONSE
ThreadLocal storage for response.

## Constructor Details

### HttpServletRequestResponseContext

private HttpServletRequestResponseContext()
Constructor.

## Method Details

### loadCurrent

public static void loadCurrent(@Nonnull HttpServletRequest request, @Nonnull HttpServletResponse response)
Load the thread-local storage with the current request and response.

Parameters:
  `request` - the current `HttpServletRequest`
  `response` - the current `HttpServletResponse`

### clearCurrent

public static void clearCurrent()
Clear the current thread-local context instances.

### getRequest

@Nullable public static HttpServletRequest getRequest()
Get the current `HttpServletRequest` being serviced by the current thread.

Returns:
  the current request

### getResponse

@Nullable public static HttpServletResponse getResponse()
Get the current `HttpServletResponse` being serviced by the current thread.

Returns:
  the current response