tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Fennell <>
Subject Includes that Forward
Date Fri, 07 Jul 2006 12:28:16 GMT

I'm wondering what the expected behaviour is when a JSP that is 
included from another JSP then forwards to a third JSP?  As an example:
    - start.jsp
        - some content on start.jsp
        - _include_ included.jsp
            - some content on included.jsp
            - _forward_ to forwarded.jsp
                - content on forwarded.jsp
            - some content (on included.jsp) after the forward
        - some content on start.jsp after the include

Does the above example make sense?  I was able to dig up this bug 
(which was closed INVALID) for Tomcat 4:

I'm using Tomcat 5.5.17 and what happens is that *only* the content on 
the inner-most forwarded page is output to the response.  Actually - in 
my case it's some code deep down in the framework causing exceptions to 
be thrown, but I believe it's the same problem as exhibited by the test 
case I've put together using three JSPs.

Now, granted, the spec does say that on Forward the response buffer 
should be cleared, and after the forward it should be closed.  So it's 
arguable that Tomcat is doing the right thing.  However, I'll point out 
that Resin and Jetty 6 both do different things here - so clearly how a 
Forward is handled *inside* of an Include is open to a lot of 
interpretation.  I think the problem is that the specification doesn't 
really address the case of a Forward happening nested inside an Include 

Personally I feel like the only sensible option (from a user's 
perspective) is to treat each include in the manner of a nested 
transaction.  So in the example above, I would expect the content from 
the outer (start.jsp) page to be rendered, along with the content from 
the inner most (forwarded.jsp), but that the content from included.jsp 
would be omitted in keeping with how the servlet specification defines 
the semantics of a Forward.

Are you guys open to discussing how this is handled in Tomcat?  Btw. if 
this is a dicussion more appropriate for the dev list, just let me know 
and I'll post there instead.

-Tim Fennell
Stripes: Because web development should just be easier

To start a new topic, e-mail:
To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message