Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

org.apache.catalina.core
Class ApplicationDispatcher  view ApplicationDispatcher download ApplicationDispatcher.java

java.lang.Object
  extended byorg.apache.catalina.core.ApplicationDispatcher
All Implemented Interfaces:
javax.servlet.RequestDispatcher

final class ApplicationDispatcher
extends java.lang.Object
implements javax.servlet.RequestDispatcher

Standard implementation of 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 javax.servlet.ServletRequestWrapper and javax.servlet.ServletResponseWrapper.

Version:
$Revision: 303947 $ $Date: 2005-06-09 01:50:26 -0400 (Thu, 09 Jun 2005) $

Nested Class Summary
protected  class ApplicationDispatcher.PrivilegedForward
           
protected  class ApplicationDispatcher.PrivilegedInclude
           
 
Field Summary
private  javax.servlet.ServletRequest appRequest
          The request specified by the dispatching application.
private  javax.servlet.ServletResponse appResponse
          The response specified by the dispatching application.
private  org.apache.catalina.Context context
          The Context this RequestDispatcher is associated with.
private  boolean including
          Are we performing an include() instead of a forward()?
private static java.lang.String info
          Descriptive information about this implementation.
private static org.apache.commons.logging.Log log
           
private  java.lang.String name
          The servlet name for a named dispatcher.
private  java.lang.String origServletPath
           
private  javax.servlet.ServletRequest outerRequest
          The outermost request that will be passed on to the invoked servlet.
private  javax.servlet.ServletResponse outerResponse
          The outermost response that will be passed on to the invoked servlet.
private  java.lang.String pathInfo
          The extra path information for this RequestDispatcher.
private  java.lang.String queryString
          The query string parameters for this RequestDispatcher.
private  java.lang.String requestURI
          The request URI for this RequestDispatcher.
private  java.lang.String servletPath
          The servlet path for this RequestDispatcher.
private static org.apache.catalina.util.StringManager sm
          The StringManager for this package.
private  org.apache.catalina.util.InstanceSupport support
          The InstanceSupport instance associated with our Wrapper (used to send "before dispatch" and "after dispatch" events.
private  org.apache.catalina.Wrapper wrapper
          The Wrapper associated with the resource that will be forwarded to or included.
private  javax.servlet.ServletRequest wrapRequest
          The request wrapper we have created and installed (if any).
private  javax.servlet.ServletResponse wrapResponse
          The response wrapper we have created and installed (if any).
 
Constructor Summary
ApplicationDispatcher(org.apache.catalina.Wrapper wrapper, java.lang.String requestURI, java.lang.String servletPath, java.lang.String pathInfo, java.lang.String queryString, java.lang.String name)
          Construct a new instance of this class, configured according to the specified parameters.
 
Method Summary
private  void doForward(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
           
private  void doInclude(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
           
 void forward(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
          Forward this request and response to another resource for processing.
 java.lang.String getInfo()
          Return the descriptive information about this implementation.
 void include(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
          Include the response from another resource in the current response.
private  void invoke(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
          Ask the resource represented by this RequestDispatcher to process the associated request, and create (or append to) the associated response.
private  void processRequest(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response)
          Prepare the request based on the filter configuration.
private  void setup(javax.servlet.ServletRequest request, javax.servlet.ServletResponse response, boolean including)
          Set up to handle the specified request and response
private  void unwrapRequest()
          Unwrap the request if we have wrapped it.
private  void unwrapResponse()
          Unwrap the response if we have wrapped it.
private  javax.servlet.ServletRequest wrapRequest()
          Create and return a request wrapper that has been inserted in the appropriate spot in the request chain.
private  javax.servlet.ServletResponse wrapResponse()
          Create and return a response wrapper that has been inserted in the appropriate spot in the response chain.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static org.apache.commons.logging.Log log

appRequest

private javax.servlet.ServletRequest appRequest
The request specified by the dispatching application.


appResponse

private javax.servlet.ServletResponse appResponse
The response specified by the dispatching application.


context

private org.apache.catalina.Context context
The Context this RequestDispatcher is associated with.


including

private boolean including
Are we performing an include() instead of a forward()?


info

private static final java.lang.String info
Descriptive information about this implementation.

See Also:
Constant Field Values

name

private java.lang.String name
The servlet name for a named dispatcher.


outerRequest

private javax.servlet.ServletRequest outerRequest
The outermost request that will be passed on to the invoked servlet.


outerResponse

private javax.servlet.ServletResponse outerResponse
The outermost response that will be passed on to the invoked servlet.


pathInfo

private java.lang.String pathInfo
The extra path information for this RequestDispatcher.


queryString

private java.lang.String queryString
The query string parameters for this RequestDispatcher.


requestURI

private java.lang.String requestURI
The request URI for this RequestDispatcher.


servletPath

private java.lang.String servletPath
The servlet path for this RequestDispatcher.


origServletPath

private java.lang.String origServletPath

sm

private static final org.apache.catalina.util.StringManager sm
The StringManager for this package.


support

private org.apache.catalina.util.InstanceSupport support
The InstanceSupport instance associated with our Wrapper (used to send "before dispatch" and "after dispatch" events.


wrapper

private org.apache.catalina.Wrapper wrapper
The Wrapper associated with the resource that will be forwarded to or included.


wrapRequest

private javax.servlet.ServletRequest wrapRequest
The request wrapper we have created and installed (if any).


wrapResponse

private javax.servlet.ServletResponse wrapResponse
The response wrapper we have created and installed (if any).

Constructor Detail

ApplicationDispatcher

public ApplicationDispatcher(org.apache.catalina.Wrapper wrapper,
                             java.lang.String requestURI,
                             java.lang.String servletPath,
                             java.lang.String pathInfo,
                             java.lang.String queryString,
                             java.lang.String name)
Construct a new instance of this class, configured according to the specified parameters. If both servletPath and pathInfo are null, it will be assumed that this RequestDispatcher was acquired by name, rather than by path.

Method Detail

getInfo

public java.lang.String getInfo()
Return the descriptive information about this implementation.


forward

public void forward(javax.servlet.ServletRequest request,
                    javax.servlet.ServletResponse response)
             throws javax.servlet.ServletException,
                    java.io.IOException
Forward this request and response to another resource for processing. Any runtime exception, IOException, or ServletException thrown by the called servlet will be propogated to the caller.

Specified by:
forward in interface javax.servlet.RequestDispatcher

doForward

private void doForward(javax.servlet.ServletRequest request,
                       javax.servlet.ServletResponse response)
                throws javax.servlet.ServletException,
                       java.io.IOException

processRequest

private void processRequest(javax.servlet.ServletRequest request,
                            javax.servlet.ServletResponse response)
                     throws java.io.IOException,
                            javax.servlet.ServletException
Prepare the request based on the filter configuration.


include

public void include(javax.servlet.ServletRequest request,
                    javax.servlet.ServletResponse response)
             throws javax.servlet.ServletException,
                    java.io.IOException
Include the response from another resource in the current response. Any runtime exception, IOException, or ServletException thrown by the called servlet will be propogated to the caller.

Specified by:
include in interface javax.servlet.RequestDispatcher

doInclude

private void doInclude(javax.servlet.ServletRequest request,
                       javax.servlet.ServletResponse response)
                throws javax.servlet.ServletException,
                       java.io.IOException

invoke

private void invoke(javax.servlet.ServletRequest request,
                    javax.servlet.ServletResponse response)
             throws java.io.IOException,
                    javax.servlet.ServletException
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.


setup

private void setup(javax.servlet.ServletRequest request,
                   javax.servlet.ServletResponse response,
                   boolean including)
Set up to handle the specified request and response


unwrapRequest

private void unwrapRequest()
Unwrap the request if we have wrapped it.


unwrapResponse

private void unwrapResponse()
Unwrap the response if we have wrapped it.


wrapRequest

private javax.servlet.ServletRequest wrapRequest()
Create and return a request wrapper that has been inserted in the appropriate spot in the request chain.


wrapResponse

private javax.servlet.ServletResponse wrapResponse()
Create and return a response wrapper that has been inserted in the appropriate spot in the response chain.