Nick, There appears to be problems with RequestDispatcher. There are several open issues related to it. Some appear to report this exact behavior. http://code.google.com/p/google-guice/issues/list?q=requestdispatcher
Sam would want a unit test that expresses the bug. -- TJ On Fri, May 20, 2011 at 12:58 AM, Nick Lothian <[email protected]>wrote: > > Hi, > > I'm trying to use UrlRewriteFilter ( > http://code.google.com/p/urlrewritefilter/ - basically Apache mod_rewrite > implemented in a filter) with Guice. I've found that request parameters seem > to get stripped off when dispatching to a Guice managed Servlet. > > I wrote a simple servlet to confirm this: > > Non Guice-managed servlet, mapped in web.xml to "/test" > > @Override > protected void doGet(HttpServletRequest request, HttpServletResponse > response) throws ServletException, IOException { > RequestDispatcher rd = > request.getRequestDispatcher("/album?username=hello"); > rd.forward(request, response); > } > > Guice mapping: > > serve("/album*").with(AlbumController.class); > > Guice-managed Servlet: > > String albumOwnerUsername = req.getParameter("username"); > System.out.println(req.getParameterMap()); > System.out.println(albumOwnerUsername); > > If I visit /test, I get the following outputted: > > {} > null > > (ie, the parameter has been lost. Visting "/album?username=hello" works > correctly) > > I've seen a few previous postings about this, but never a resolution or a > real explanation for why this should(?) happen. > > I did some browsing in the Guice code, and found the following comment - > which might be totally unrelated - or might indicate this behaviour is by > design. > > // TODO(dhanji): check servlet spec to see if the following is legal > or not. > // Need to strip query string if requested... > > > http://code.google.com/p/google-guice/source/browse/trunk/extensions/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java#11<http://code.google.com/p/google-guice/source/browse/trunk/extensions/servlet/src/com/google/inject/servlet/ManagedServletPipeline.java#116> > 5 > > (I can't actually see where the parameters are being stripped, though) > > Either way - is this a bug? Or can someone please explain why Guice needs > to strip the parameters? > > Thanks > Nick > > > > > > > > > > > -- > You received this message because you are subscribed to the Google Groups > "google-guice" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/google-guice?hl=en. > -- You received this message because you are subscribed to the Google Groups "google-guice" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
