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 |
|---|---|
| protected class | |
| protected class | |
| protected class | |
| private static class | ApplicationDispatcher.
Used to pass state when the request dispatcher is used. |
| Modifier and Type | Field and Description |
|---|---|
| private final Context | context
The Context this RequestDispatcher is associated with. |
| private final HttpServletMapping | mapping
The mapping for this RequestDispatcher. |
| private final String | name
The servlet name for a named dispatcher. |
| private final String | pathInfo
The extra path information for this RequestDispatcher. |
| private final String | queryString
The query string parameters for this RequestDispatcher. |
| private final String | requestURI
The request URI for this RequestDispatcher. |
| private final String | servletPath
The servlet path for this RequestDispatcher. |
| private static final StringManager | sm
The StringManager for this package. |
| private final Wrapper | wrapper
The Wrapper associated with the resource that will be forwarded to or included. |
| Access | Constructor and Description |
|---|---|
| pack-priv | ApplicationDispatcher(Wrapper
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, HttpServletMapping The mapping for this resource (if any) mapping, 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 void | |
| public void | dispatch(ServletRequest
The request object to pass to the dispatch target request, ServletResponse The response object to pass to the dispatch target response)Implements org. Perform an asynchronous dispatch. |
| private void | |
| private void | |
| private void | |
| public void | forward(ServletRequest
The servlet request to be forwarded request, ServletResponse The servlet response to be forwarded response)Implements jakarta. Forward this request and response to another resource for processing. |
| private String | Returns: The combined path with pathInfo appended to servletInfoCombine 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.The RD state statePrepare 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. |
| context | back to summary |
|---|---|
| private final Context context The Context this RequestDispatcher is associated with. | |
| mapping | back to summary |
|---|---|
| private final HttpServletMapping mapping The mapping for this RequestDispatcher. | |
| name | back to summary |
|---|---|
| private final String name The servlet name for a named dispatcher. | |
| pathInfo | back to summary |
|---|---|
| private final String pathInfo The extra path information for this RequestDispatcher. | |
| queryString | back to summary |
|---|---|
| private final String queryString The query string parameters for this RequestDispatcher. | |
| requestURI | back to summary |
|---|---|
| private final String requestURI The request URI for this RequestDispatcher. | |
| servletPath | back to summary |
|---|---|
| private final String servletPath The servlet path for this RequestDispatcher. | |
| sm | back to summary |
|---|---|
| private static final StringManager sm The StringManager for this package. | |
| wrapper | back to summary |
|---|---|
| private final Wrapper wrapper The Wrapper associated with the resource that will be forwarded to or included. | |
| ApplicationDispatcher | back to summary |
|---|---|
| pack-priv ApplicationDispatcher(Wrapper wrapper, String requestURI, String servletPath, String pathInfo, String queryString, HttpServletMapping mapping, String name) Construct a new instance of this class, configured according to the specified parameters. If both servletPath and
pathInfo are
| |
| checkSameObjects | back to summary |
|---|---|
| private void checkSameObjects(ServletRequest appRequest, ServletResponse appResponse) throws ServletException | |
| dispatch | back to summary |
|---|---|
| public void dispatch(ServletRequest request, ServletResponse response) throws ServletException, IOException Implements org. Doc from org. Perform an asynchronous dispatch. The method does not check if the request is in an appropriate state for this; it is the caller's responsibility to check this.
| |
| doDispatch | back to summary |
|---|---|
| private void doDispatch(ServletRequest request, ServletResponse response) throws ServletException, IOException | |
| doForward | back to summary |
|---|---|
| private void doForward(ServletRequest request, ServletResponse response) throws ServletException, IOException | |
| doInclude | back to summary |
|---|---|
| private void doInclude(ServletRequest request, ServletResponse response) throws ServletException, IOException | |
| forward | back to summary |
|---|---|
| public void forward(ServletRequest request, ServletResponse response) throws ServletException, IOException Implements jakarta. Forward this request and response to another resource for processing. Any runtime exception, IOException, or ServletException thrown by the called servlet will be propagated to the caller.
| |
| getCombinedPath | back to summary |
|---|---|
| private String getCombinedPath() Combine 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 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 | |
| PrivilegedDispatch | back to summary |
|---|---|
| pack-priv PrivilegedDispatch(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 |
|---|---|
| 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 | |
| PrivilegedForward | back to summary |
|---|---|
| pack-priv PrivilegedForward(ServletRequest request, ServletResponse response) | |
| 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 HttpServletRequest | hrequest
Outermost HttpServletRequest in the chain |
| pack-priv HttpServletResponse | hresponse
Outermost HttpServletResponse in the chain |
| pack-priv boolean | including
Are we performing an include() instead of a forward()? |
| pack-priv ServletRequest | outerRequest
The outermost request that will be passed on to the invoked servlet. |
| pack-priv ServletResponse | outerResponse
The outermost response that will be passed on to the invoked servlet. |
| pack-priv ServletRequest | wrapRequest
The request wrapper we have created and installed (if any). |
| pack-priv ServletResponse | wrapResponse
The response wrapper we have created and installed (if any). |
| Access | Constructor and Description |
|---|---|
| pack-priv |
| 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 | |
| including | back to summary |
|---|---|
| pack-priv boolean including Are we performing an include() instead of a forward()? | |
| outerRequest | back to summary |
|---|---|
| pack-priv ServletRequest outerRequest The outermost request that will be passed on to the invoked servlet. | |
| outerResponse | back to summary |
|---|---|
| pack-priv ServletResponse outerResponse The outermost response that will be passed on to the invoked servlet. | |
| wrapRequest | back to summary |
|---|---|
| pack-priv ServletRequest wrapRequest The request wrapper we have created and installed (if any). | |
| wrapResponse | back to summary |
|---|---|
| pack-priv ServletResponse wrapResponse The response wrapper we have created and installed (if any). | |
| State | back to summary |
|---|---|
| pack-priv State(ServletRequest request, ServletResponse response, boolean including) | |