google / google/guice

Provider<ServletRequest> does not provide a wrapped servlet request capable of executing RequestDispatcher.include

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

Description

_From [steve.skrla](https://code.google.com/u/113732569052853304526/) on January 05, 2011 19:10:36_

I am using Guice 2.0 (Maven artifact) and Tomcat 6.x / 7.x on Ubuntu.

When I try to inject a ServletRequest with a provider (and I suspect even directly), the object provided is not of type ManagedFilterPipeline$2, which I believe is the type provided to the service(HttpServletRequest, HttpServletResponse) methods of guice managed servlets and required for the include and forward methods to work. As a result, the getRequestDispatcher(String) method does not return a dispatcher that is aware of the guice managed servlets and my include calls fail to resolve the appropriate servlets.

example:

Module.class
    serve("/dwr/*").with(DwrServlet.class);

SomeServlet.class
    protected void service(HttpServletRequest req, HttpServletResponse resp) {
        // Works as expected
        req.getRequestDispatcher("/dwr/engine.js").include(req, resp);
    }

SomeBrokenUtility.class
    class SomeBrokenUtility {
        `@`Inject Provider<ServletRequest> requestProvider;

        public String pullFromDwr() {
            FakeHttpResponse resp = ...;
 
            ServletRequest req = requestProvider.get();

            // Throws a FileNotFoundException as the DefaultServlet cannot
            // locate the requested resource
            req.getRequestDispatcher("/dwr/engine.js").include(req, resp);

            return resp.getResponseAsString();
        }
    }

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

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.