google / google/guice

ServeltContext#getRequestDispatcher cannot forward to Guice Servlets

Open
#621 2 comments 0 reactions 0 assignees View on GitHub
imported
Dominant language
Java
Stars
12.7k
Forks
1.7k
Avg merge
11m
Merged PRs (30d)
2

Description

_From [ori.schwartz](https://code.google.com/u/110373506924261012635/) on April 05, 2011 12:55:31_

Here is the simplest test case (I'm using tomcat 5.5.33):

\* Use Guice ServletModule to configure two servlets, one of which just dispatches to the other:

    protected void configureServlets()
    {
        serve( "/dispatcher" ).with( DispatcherServlet.class );
        serve( "/dispatchee" ).with( DispatcheeServlet.class );
    }

\* Dispatchee outputs text for verification, dispatcher redirects like this:

        protected void doGet( HttpServletRequest req, HttpServletResponse resp )
            throws ServletException, IOException
        {
            this.getServletContext().getRequestDispatcher( "/dispatchee" )
                .forward( req, resp );
        }

\* Invoking /dispatcher yields a blank page with a 404 status that is incorrectly served up by Tomcat's default servlet.

\* When configuring via traditional web.xml instead of guice, everything works as expected.

\* I did some debugging and it looks like Tomcat's internal pattern matching inside its RequestDispatcher implementation isn't even aware of the servlet mapping that Guice configured.

To fix it sounds like Guice will have to wrap the RequestDispatcher object returned from ServletContext to route requests appropriately (see discussion on issue 372 ).

**Attachment:** [gist](https://gist.github.com/b2761752b07cbcf27530)
   _[GuiceRequestDispatcherBug.java](https://gist.githubusercontent.com/gissuebot/b2761752b07cbcf27530/raw/db3de8f6059df917729c8372964e8d53c2c03255/GuiceRequestDispatcherBug.java)_

_Original issue: http://code.google.com/p/google-guice/issues/detail?id=621_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.