I gave it a quick go (trunk build) and it to works with jsp out of the
box but it is not perfect(calling include works but calling forward
crashes).
IIRC There are 2 different ways of getting the RequestDispatcher
o) From ServletContext in that case you specify the whole path
context.getRequestDispatcher("/fooServlet/whatever.html") it begins
with / i.e. the root
o) From ServletRequest in that case you specify only the part that
comes after the servlet since the request knows for which servlet it
belongs e.g. request.getRequestDispatcher("whatever.html"). Note the "/
fooServlet/" is figured out from the request.
You're doing req.getRequestDispatcher( "/WEB-INF/jsp/test.jsp"). I
could be wrong but you are doing the request way your request is
actually for /<servlet>//WEB-INF/jsp/test.jsp beside I think that
request for WEB-INF/* should return 404 in any case. WEB-INF is
private property.
You can try @Inject ServletContext ctx; and doing
ctx.getRequestDispatcher("/jsp/test.jsp") or properly use request way.
I noticed
serve( "/test" ).with( TestServlet.class );
If you try /test in the browser it will return 404 since the browser
actually requests /test/ notice the trailing /. Try
serve( "/test/" ).with( TestServlet.class )
Dhanji maybe "/test" and "/test/" should be equivalent in serve
definition? At least I noticed that trailing / makes a big difference.
Anyway. Oddly enough
requestDispatcher = either from context (long path) or request (short
path)
requestDispatcher.forward(httpServletRequest, httpServletResponse); //
this produces SIOOBE WTF?
requestDispatcher.include(httpServletRequest, httpServletResponse); //
works browser returns the correct response
Cheers,
Alen
On May 4, 12:55 am, "Dhanji R. Prasanna" <[email protected]> wrote:
> Yea you're right that that is basically the problem. I'll look into this
> when I have some time later in the month. Any other volunteers?
> Dhanji.
>
> On Mon, May 4, 2009 at 2:45 AM, tchan <[email protected]> wrote:
>
> > All right, I took a stab at it and managed to find the problem but I
> > don't understand it well enough to fix it.
>
> > In Tomcat, the forward to the referenced jsp will eventually be
> > serviced by the Jasper jsp servlet. When the target jsp is defined in
> > web.xml, it can just grab its path from that servlet definition entry
> > otherwise it has to be a request from RequestDispatcher. So if it's
> > an include, then there's a request attribute with the path already
> > otherwise for a forward, Jasper will call request.getServletPath() and
> > append getPathInfo() on it as needed. This is where the problem is.
>
> > The request object here is a Guice wrapper object, specifically the
> > anonymous HttpServletRequestWrapper class inside
> > ServletDefinition.doService(). Its getServlePath() defers to
> > computePath() to figure out the servlet path and it *seems* to return
> > the servlet mapping of the original servlet rather than the servlet
> > path of the jsp forward. computePath() does defer to its super
> > (Tomcat) request object if it can't compute it itself and that wrapped
> > request object returns the right servlet path.
>
> > So in short, the request wrapper in ServletDefinition has a bug that
> > trips jsp forwards in Tomcat. But I don't understand why it does what
> > it tries to do so I'll have to leave it to Dhanji to take a look at
> > it.
>
> > On May 3, 8:51 am, tchan <[email protected]> wrote:
> > > I don`t mind taking a stab at ii if you can point me in the right
> > > direction. I tried debugging through Tomcat`s pipeline but that was
> > > too much for me (and I really couldn`t see a difference between the
> > > web.xml and GuiceFilter scenarios).
>
> > > On May 3, 12:25 am, "Dhanji R. Prasanna" <[email protected]> wrote:
>
> > > > yea this is a known problem, I just have not had any time to address it
> > =(
> > > > If you would like to contribute a patch we would be thrilled! Otherwise
> > I
> > > > hope to get to this problem soon.
>
> > > > Dhanji.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---