The problem is partially fixed in guice and guice servlet 3.1.1 with one problem:
When matching a servlet using the asterisk '/ *' pattern, as shown below:
serve("/myservlet/*").with(MyServlet.class);
And send MyServlet.java to the jsp page, then the forward () function will work only if there are no underlining on the jsp page (so myservlet.jsp will work, my_servlet.jsp will not work).
// This WORKS req.getRequestDispatcher("/myservlet.jsp").forward(req,resp); // These DONT WORK (any file having _ or - characetsrs wont work) req.getRequestDispatcher("/my_servlet.jsp").forward(req,resp); req.getRequestDispatcher("/my-servlet.jsp").forward(req,resp); req.getRequestDispatcher("/WEB-INF/myservlet.jsp").forward(req,resp);
Now this explains why WEB-INF forwarding does not work for the servlet associated with / *. The reason is because WEB-INF contains a dash, which for some reason creates a problem for the guice servlet. If you try to run the above example, be sure to rename the myservlet.jsp file to my_servlet.jsp when trying to verify this case.
I have no idea why this strange case is taking place. NOTE. I am using Tomcat 6.0.35
To Guice 3.1.1 add them to your pom.xml
<dependency> <groupId>org.sonatype.sisu</groupId> <artifactId>sisu-guice</artifactId> <version>3.1.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.sonatype.sisu.inject</groupId> <artifactId>guice-servlet</artifactId> <version>3.1.1</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.sonatype.sisu.inject</groupId> <artifactId>guice-assistedinject</artifactId> <version>3.1.1</version> <scope>compile</scope> </dependency>
Or you can download jars from:
Guice servlet jug
http://repo1.maven.org/maven2/org/sonatype/sisu/inject/guice-servlet/3.1.1/
Guice jar
http://repo1.maven.org/maven2/org/sonatype/sisu/sisu-guice/3.1.1/
source share