RequestDispatcher that allows a request to be forwarded to a different
resource to create the ultimate response, or to include the output of another resource in the response from this
resource. This implementation allows application level servlets to wrap the request and/or response objects that are
passed on to the called resource, as long as the wrapping classes extend
jakarta.servlet.ServletRequestWrapper and jakarta.servlet.ServletResponseWrapper.
| Modifier and Type | Class and Description |
|---|---|
| private class | |
| private class | |
| private static class | ApplicationDispatcher.
Used to pass state when the request dispatcher is used. |
| Modifier and Type | Field and Description |
|---|---|
| private Boolean | crossContextFlag
is this dispatch cross context |
| public static final String | |
| private static final Logger | |
| private String | name
The servlet name for a named dispatcher. |
| private String | pathInfo
The extra path information for this RequestDispatcher. |
| private String | queryString
The query string parameters for this RequestDispatcher. |
| private String | requestURI
The request URI for this RequestDispatcher. |
| private String | servletPath
The servlet path for this RequestDispatcher. |
| private ServletHandler | wrapper
The Wrapper associated with the resource that will be forwarded to or included. |
| Access | Constructor and Description |
|---|---|
| public | ApplicationDispatcher(ServletHandler
The Wrapper associated with the resource that will be forwarded to or included (required) wrapper, String The request URI to this resource (if any) requestURI, String The revised servlet path to this resource (if any) servletPath, String The revised extra path information to this resource (if any) pathInfo, String Query string parameters included with this request (if any) queryString, String Servlet name (if a named dispatcher was created) else name)nullConstruct a new instance of this class, configured according to the specified parameters. |
| Modifier and Type | Method and Description |
|---|---|
| private static void | |
| public void | dispatch(ServletRequest
The request to be forwarded request, ServletResponse The response to be forwarded response, DispatcherType The type of dispatch to be performed dispatcherType)Dispatches the given request and response to the resource for which this dispatcher was acquired. |
| private void | |
| private void | |
| private void | doInvoke(ServletRequest
The servlet request we are processing request, ServletResponse The servlet response we are creating response, boolean true if the request dispatch is crossing context boundaries, false otherwise crossContext, ApplicationDispatcher.the state of this ApplicationDispatcher stateAsk the resource represented by this RequestDispatcher to process the associated request, and create (or append to) the associated response. |
| public void | forward(ServletRequest
The request to be forwarded request, ServletResponse The response to be forwarded response)Implements jakarta. Forwards the given request and response to the resource for which this dispatcher was acquired. |
| private String | Returns: The combined path with pathInfo appended to servletInfoCombines the servletPath and the pathInfo. |
| public void | include(ServletRequest
The servlet request that is including this one request, ServletResponse The servlet response to be appended to response)Implements jakarta. Include the response from another resource in the current response. |
| private void | invoke(ServletRequest
The servlet request we are processing request, ServletResponse The servlet response we are creating response, ApplicationDispatcher.Ask the resource represented by this RequestDispatcher to process the associated request, and create (or append to) the associated response. |
| private void | processRequest(ServletRequest
The servlet request we are processing request, ServletResponse The servlet response we are creating response, ApplicationDispatcher.Prepare the request based on the filter configuration. |
| private void | |
| private void | |
| private void | |
| private ServletRequest | wrapRequest(ApplicationDispatcher.
Create and return a request wrapper that has been inserted in the appropriate spot in the request chain. |
| private ServletResponse | wrapResponse(ApplicationDispatcher.
Create and return a response wrapper that has been inserted in the appropriate spot in the response chain. |
| crossContextFlag | back to summary |
|---|---|
| private Boolean crossContextFlag is this dispatch cross context | |
| LAST_DISPATCH_REQUEST_PATH_ATTR | back to summary |
|---|---|
| public static final String LAST_DISPATCH_REQUEST_PATH_ATTR | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| name | back to summary |
|---|---|
| private String name The servlet name for a named dispatcher. | |
| pathInfo | back to summary |
|---|---|
| private String pathInfo The extra path information for this RequestDispatcher. | |
| queryString | back to summary |
|---|---|
| private String queryString The query string parameters for this RequestDispatcher. | |
| requestURI | back to summary |
|---|---|
| private String requestURI The request URI for this RequestDispatcher. | |
| servletPath | back to summary |
|---|---|
| private String servletPath The servlet path for this RequestDispatcher. | |
| wrapper | back to summary |
|---|---|
| private ServletHandler wrapper The Wrapper associated with the resource that will be forwarded to or included. | |
| ApplicationDispatcher | back to summary |
|---|---|
| public ApplicationDispatcher(ServletHandler wrapper, String requestURI, String servletPath, String pathInfo, String queryString, String name) Construct a new instance of this class, configured according to the specified parameters. If both servletPath and
pathInfo are
| |
| closeResponse | back to summary |
|---|---|
| private static void closeResponse(ServletResponse response) | |
| dispatch | back to summary |
|---|---|
| public void dispatch(ServletRequest request, ServletResponse response, DispatcherType dispatcherType) throws ServletException, IOException Dispatches the given request and response to the resource for which this dispatcher was acquired. Any runtime exceptions, IOException, or ServletException thrown by the target will be propagated to the caller.
| |
| doDispatch | back to summary |
|---|---|
| private void doDispatch(ServletRequest request, ServletResponse response, DispatcherType dispatcherType) throws ServletException, IOException | |
| doInclude | back to summary |
|---|---|
| private void doInclude(ServletRequest request, ServletResponse response) throws ServletException, IOException | |
| doInvoke | back to summary |
|---|---|
| private void doInvoke(ServletRequest request, ServletResponse response, boolean crossContext, ApplicationDispatcher. Ask the resource represented by this RequestDispatcher to process the associated request, and create (or append to) the associated response. Implementation Note This implementation assumes that no filters are applied to a forwarded or included resource, because they were already done for the original request.
| |
| forward | back to summary |
|---|---|
| public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException Implements jakarta. Forwards the given request and response to the resource for which this dispatcher was acquired. Any runtime exceptions, IOException, or ServletException thrown by the target will be propagated to the caller.
| |
| getCombinedPath | back to summary |
|---|---|
| private String getCombinedPath() Combines the servletPath and the pathInfo.
If pathInfo is
| |
| include | back to summary |
|---|---|
| public void include(ServletRequest request, ServletResponse response) throws ServletException, IOException Implements jakarta. Include the response from another resource in the current response. Any runtime exception, IOException, or ServletException thrown by the called servlet will be propagated to the caller.
| |
| invoke | back to summary |
|---|---|
| private void invoke(ServletRequest request, ServletResponse response, ApplicationDispatcher. Ask the resource represented by this RequestDispatcher to process the associated request, and create (or append to) the associated response. Implementation Note This implementation assumes that no filters are applied to a forwarded or included resource, because they were already done for the original request.
| |
| processRequest | back to summary |
|---|---|
| private void processRequest(ServletRequest request, ServletResponse response, ApplicationDispatcher. Prepare the request based on the filter configuration.
| |
| recycleRequestWrapper | back to summary |
|---|---|
| private void recycleRequestWrapper(ApplicationDispatcher. | |
| unwrapRequest | back to summary |
|---|---|
| private void unwrapRequest(ApplicationDispatcher. Unwrap the request if we have wrapped it. | |
| unwrapResponse | back to summary |
|---|---|
| private void unwrapResponse(ApplicationDispatcher. Unwrap the response if we have wrapped it. | |
| wrapRequest | back to summary |
|---|---|
| private ServletRequest wrapRequest(ApplicationDispatcher. Create and return a request wrapper that has been inserted in the appropriate spot in the request chain. | |
| wrapResponse | back to summary |
|---|---|
| private ServletResponse wrapResponse(ApplicationDispatcher. Create and return a response wrapper that has been inserted in the appropriate spot in the response chain. | |
| Modifier and Type | Field and Description |
|---|---|
| private final DispatcherType | |
| private final ServletRequest | |
| private final ServletResponse |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Void |
| dispatcherType | back to summary |
|---|---|
| private final DispatcherType dispatcherType | |
| request | back to summary |
|---|---|
| private final ServletRequest request | |
| response | back to summary |
|---|---|
| private final ServletResponse response | |
| PrivilegedDispatch | back to summary |
|---|---|
| pack-priv PrivilegedDispatch(ServletRequest request, ServletResponse response, DispatcherType dispatcherType) | |
| run | back to summary |
|---|---|
| public Void run() throws Exception Implements java. Doc from java. Performs the computation. This method will be called by
| |
| Modifier and Type | Field and Description |
|---|---|
| private final ServletRequest | |
| private final ServletResponse |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public Void |
| request | back to summary |
|---|---|
| private final ServletRequest request | |
| response | back to summary |
|---|---|
| private final ServletResponse response | |
| PrivilegedInclude | back to summary |
|---|---|
| pack-priv PrivilegedInclude(ServletRequest request, ServletResponse response) | |
| run | back to summary |
|---|---|
| public Void run() throws ServletException, IOException Implements java. Doc from java. Performs the computation. This method will be called by
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv final DispatcherType | dispatcherType
The type of dispatch we are performing |
| pack-priv HttpServletRequest | hrequest
Outermost HttpServletRequest in the chain |
| pack-priv HttpServletResponse | hresponse
Outermost HttpServletResponse in the chain |
| pack-priv ServletRequest | outerRequest
Outermost request that will be passed on to the invoked servlet |
| pack-priv ServletResponse | outerResponse
Outermost response that will be passed on to the invoked servlet. |
| pack-priv ServletRequest | wrapRequest
Request wrapper we have created and installed (if any). |
| pack-priv ServletResponse | wrapResponse
Response wrapper we have created and installed (if any). |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| dispatcherType | back to summary |
|---|---|
| pack-priv final DispatcherType dispatcherType The type of dispatch we are performing | |
| hrequest | back to summary |
|---|---|
| pack-priv HttpServletRequest hrequest Outermost HttpServletRequest in the chain | |
| hresponse | back to summary |
|---|---|
| pack-priv HttpServletResponse hresponse Outermost HttpServletResponse in the chain | |
| outerRequest | back to summary |
|---|---|
| pack-priv ServletRequest outerRequest Outermost request that will be passed on to the invoked servlet | |
| outerResponse | back to summary |
|---|---|
| pack-priv ServletResponse outerResponse Outermost response that will be passed on to the invoked servlet. | |
| wrapRequest | back to summary |
|---|---|
| pack-priv ServletRequest wrapRequest Request wrapper we have created and installed (if any). | |
| wrapResponse | back to summary |
|---|---|
| pack-priv ServletResponse wrapResponse Response wrapper we have created and installed (if any). | |
| State | back to summary |
|---|---|
| pack-priv State(ServletRequest request, ServletResponse response, DispatcherType dispatcherType) | |