Top Description Fields Constructors Methods
io.undertow.servlet.handlers

public Class ServletRequestContext

extends Object
Class Inheritance
Imports
java.net.InetAddress, .InetSocketAddress, java.util.List, io.undertow.UndertowMessages, io.undertow.server.HttpServerExchange, io.undertow.servlet.api.Deployment, .ServletStackTraces, .TransportGuaranteeType, .SingleConstraintMatch, io.undertow.servlet.spec.HttpServletRequestImpl, .HttpServletResponseImpl, .HttpSessionImpl, .ServletContextImpl, io.undertow.util.AttachmentKey, .Headers, jakarta.servlet.DispatcherType, .ServletRequest, .ServletResponse

All the information that servlet needs to attach to the exchange.

This is all stored under this class, rather than using individual attachments, as this approach has significant performance advantages.

The ServletInitialHandler also pushed this information to the CURRENT thread local, which allows it to be access even if the request or response have been wrapped with non-compliant wrapper classes.

Author
Stuart Douglas

Field Summary

Modifier and TypeField and Description
private boolean
public static final AttachmentKey<ServletRequestContext>
private static final ThreadLocal<ServletRequestContext>
private ServletChain
private ServletContextImpl
private final Deployment
private DispatcherType
private int
private String
private static final RuntimePermission
private final HttpServletRequestImpl
private final HttpServletResponseImpl
private final ServletPathMatch
private String
private List<SingleConstraintMatch>
private boolean
runningInsideHandler

If this is true the request is running inside the context of ServletInitialHandler

private ServletPathMatch
private ServletRequest
private ServletResponse
private HttpSessionImpl
private static final RuntimePermission
private TransportGuaranteeType

Constructor Summary

AccessConstructor and Description
public
ServletRequestContext(final Deployment deployment, final HttpServletRequestImpl originalRequest, final HttpServletResponseImpl originalResponse, final ServletPathMatch originalServletPathMatch)

Method Summary

Modifier and TypeMethod and Description
public static void
public static ServletRequestContext

Returns:

The current ServletRequestContext based on the calling thread, or null if unavailable
current
()

Gets the current threads ServletRequestContext if set, otherwise null.

public boolean
public ServletChain
public ServletContextImpl
public Deployment
public DispatcherType
public int
public String
public HttpServerExchange
public HttpServletRequestImpl
public HttpServletResponseImpl
public ServletPathMatch
public String
public List<SingleConstraintMatch>
public ServletPathMatch
public ServletRequest
public ServletResponse
public HttpSessionImpl
public TransportGuaranteeType
public boolean
public boolean
public static ServletRequestContext

Returns:

The current ServletRequestContext based on the calling thread
requireCurrent
()

Gets the ServletRequestContext assigned to the current thread.

public void
setAsyncSupported(boolean asyncSupported)

public static void
public void
public void
public void
public void
setError(int sc, String msg)

public void
setOverridenSessionId(String overridenSessionId)

public void
public void
setRunningInsideHandler(boolean runningInsideHandler)

public void
public void
public void
public void
setSession(final HttpSessionImpl session)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asyncSupportedback to summary
private boolean asyncSupported
ATTACHMENT_KEYback to summary
public static final AttachmentKey<ServletRequestContext> ATTACHMENT_KEY
CURRENTback to summary
private static final ThreadLocal<ServletRequestContext> CURRENT
currentServletback to summary
private ServletChain currentServlet
currentServletContextback to summary
private ServletContextImpl currentServletContext
deploymentback to summary
private final Deployment deployment
dispatcherTypeback to summary
private DispatcherType dispatcherType
errorCodeback to summary
private int errorCode
errorMessageback to summary
private String errorMessage
GET_CURRENT_REQUESTback to summary
private static final RuntimePermission GET_CURRENT_REQUEST
originalRequestback to summary
private final HttpServletRequestImpl originalRequest
originalResponseback to summary
private final HttpServletResponseImpl originalResponse
originalServletPathMatchback to summary
private final ServletPathMatch originalServletPathMatch
overridenSessionIdback to summary
private String overridenSessionId
requiredConstrainsback to summary
private List<SingleConstraintMatch> requiredConstrains
runningInsideHandlerback to summary
private boolean runningInsideHandler

If this is true the request is running inside the context of ServletInitialHandler

servletPathMatchback to summary
private ServletPathMatch servletPathMatch
servletRequestback to summary
private ServletRequest servletRequest
servletResponseback to summary
private ServletResponse servletResponse
sessionback to summary
private HttpSessionImpl session
SET_CURRENT_REQUESTback to summary
private static final RuntimePermission SET_CURRENT_REQUEST
transportGuarenteeTypeback to summary
private TransportGuaranteeType transportGuarenteeType

Constructor Detail

ServletRequestContextback to summary
public ServletRequestContext(final Deployment deployment, final HttpServletRequestImpl originalRequest, final HttpServletResponseImpl originalResponse, final ServletPathMatch originalServletPathMatch)

Method Detail

clearCurrentServletAttachmentsback to summary
public static void clearCurrentServletAttachments()
currentback to summary
public static ServletRequestContext current()

Gets the current threads ServletRequestContext if set, otherwise null.

Returns:ServletRequestContext

The current ServletRequestContext based on the calling thread, or null if unavailable

displayStackTracesback to summary
public boolean displayStackTraces()
getCurrentServletback to summary
public ServletChain getCurrentServlet()
getCurrentServletContextback to summary
public ServletContextImpl getCurrentServletContext()
getDeploymentback to summary
public Deployment getDeployment()
getDispatcherTypeback to summary
public DispatcherType getDispatcherType()
getErrorCodeback to summary
public int getErrorCode()
getErrorMessageback to summary
public String getErrorMessage()
getExchangeback to summary
public HttpServerExchange getExchange()
getOriginalRequestback to summary
public HttpServletRequestImpl getOriginalRequest()
getOriginalResponseback to summary
public HttpServletResponseImpl getOriginalResponse()
getOriginalServletPathMatchback to summary
public ServletPathMatch getOriginalServletPathMatch()
getOverridenSessionIdback to summary
public String getOverridenSessionId()
getRequiredConstrainsback to summary
public List<SingleConstraintMatch> getRequiredConstrains()
getServletPathMatchback to summary
public ServletPathMatch getServletPathMatch()
getServletRequestback to summary
public ServletRequest getServletRequest()
getServletResponseback to summary
public ServletResponse getServletResponse()
getSessionback to summary
public HttpSessionImpl getSession()
getTransportGuarenteeTypeback to summary
public TransportGuaranteeType getTransportGuarenteeType()
isAsyncSupportedback to summary
public boolean isAsyncSupported()
isRunningInsideHandlerback to summary
public boolean isRunningInsideHandler()
requireCurrentback to summary
public static ServletRequestContext requireCurrent()

Gets the ServletRequestContext assigned to the current thread.

Returns:ServletRequestContext

The current ServletRequestContext based on the calling thread

Exceptions
IllegalStateException:
if the calling thread does not have a ServletRequestContext set
See Also
ServletRequestContext#current()
setAsyncSupportedback to summary
public void setAsyncSupported(boolean asyncSupported)
setCurrentRequestContextback to summary
public static void setCurrentRequestContext(ServletRequestContext servletRequestContext)
setCurrentServletback to summary
public void setCurrentServlet(ServletChain currentServlet)
setCurrentServletContextback to summary
public void setCurrentServletContext(ServletContextImpl currentServletContext)
setDispatcherTypeback to summary
public void setDispatcherType(DispatcherType dispatcherType)
setErrorback to summary
public void setError(int sc, String msg)
setOverridenSessionIdback to summary
public void setOverridenSessionId(String overridenSessionId)
setRequiredConstrainsback to summary
public void setRequiredConstrains(List<SingleConstraintMatch> requiredConstrains)
setRunningInsideHandlerback to summary
public void setRunningInsideHandler(boolean runningInsideHandler)
setServletPathMatchback to summary
public void setServletPathMatch(ServletPathMatch servletPathMatch)
setServletRequestback to summary
public void setServletRequest(ServletRequest servletRequest)
setServletResponseback to summary
public void setServletResponse(ServletResponse servletResponse)
setSessionback to summary
public void setSession(final HttpSessionImpl session)
setTransportGuarenteeTypeback to summary
public void setTransportGuarenteeType(TransportGuaranteeType transportGuarenteeType)