Class ApplicationDispatcher

  • All Implemented Interfaces:
    jakarta.servlet.RequestDispatcher

    public final class ApplicationDispatcher
    extends Object
    implements jakarta.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 jakarta.servlet.ServletRequestWrapper and jakarta.servlet.ServletResponseWrapper.
    Version:
    $Revision: 1.16 $ $Date: 2007/02/26 22:57:08 $
    Author:
    Craig R. McClanahan
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static String LAST_DISPATCH_REQUEST_PATH_ATTR  
      • Fields inherited from interface jakarta.servlet.RequestDispatcher

        ERROR_EXCEPTION, ERROR_EXCEPTION_TYPE, ERROR_MESSAGE, ERROR_REQUEST_URI, ERROR_SERVLET_NAME, ERROR_STATUS_CODE, FORWARD_CONTEXT_PATH, FORWARD_MAPPING, FORWARD_PATH_INFO, FORWARD_QUERY_STRING, FORWARD_REQUEST_URI, FORWARD_SERVLET_PATH, INCLUDE_CONTEXT_PATH, INCLUDE_MAPPING, INCLUDE_PATH_INFO, INCLUDE_QUERY_STRING, INCLUDE_REQUEST_URI, INCLUDE_SERVLET_PATH
    • Constructor Summary

      Constructors 
      Constructor Description
      ApplicationDispatcher​(Wrapper wrapper, jakarta.servlet.http.HttpServletMapping mappingForDispatch, String requestURI, String servletPath, String pathInfo, String queryString, String name)
      Construct a new instance of this class, configured according to the specified parameters.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void dispatch​(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.DispatcherType dispatcherType)
      Dispatches the given request and response to the resource for which this dispatcher was acquired.
      void forward​(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response)
      Forwards the given request and response to the resource for which this dispatcher was acquired.
      String getInfo()
      Return the descriptive information about this implementation.
      void include​(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response)
      Include the response from another resource in the current response.
    • Constructor Detail

      • ApplicationDispatcher

        public ApplicationDispatcher​(Wrapper wrapper,
                                     jakarta.servlet.http.HttpServletMapping mappingForDispatch,
                                     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 null, it will be assumed that this RequestDispatcher was acquired by name, rather than by path.
        Parameters:
        wrapper - The Wrapper associated with the resource that will be forwarded to or included (required)
        requestURI - The request URI to this resource (if any)
        servletPath - The revised servlet path to this resource (if any)
        pathInfo - The revised extra path information to this resource (if any)
        queryString - Query string parameters included with this request (if any)
        name - Servlet name (if a named dispatcher was created) else null
    • Method Detail

      • getInfo

        public String getInfo()
        Return the descriptive information about this implementation.
      • forward

        public void forward​(jakarta.servlet.ServletRequest request,
                            jakarta.servlet.ServletResponse response)
                     throws jakarta.servlet.ServletException,
                            IOException
        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.

        Specified by:
        forward in interface jakarta.servlet.RequestDispatcher
        Parameters:
        request - The request to be forwarded
        response - The response to be forwarded
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet exception occurs
      • dispatch

        public void dispatch​(jakarta.servlet.ServletRequest request,
                             jakarta.servlet.ServletResponse response,
                             jakarta.servlet.DispatcherType dispatcherType)
                      throws jakarta.servlet.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.

        Parameters:
        request - The request to be forwarded
        response - The response to be forwarded
        dispatcherType - The type of dispatch to be performed
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet exception occurs
        IllegalArgumentException - if the dispatcher type is different from FORWARD, ERROR, and ASYNC
      • include

        public void include​(jakarta.servlet.ServletRequest request,
                            jakarta.servlet.ServletResponse response)
                     throws jakarta.servlet.ServletException,
                            IOException
        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.
        Specified by:
        include in interface jakarta.servlet.RequestDispatcher
        Parameters:
        request - The servlet request that is including this one
        response - The servlet response to be appended to
        Throws:
        IOException - if an input/output error occurs
        jakarta.servlet.ServletException - if a servlet exception occurs