You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by "Michael J." <jm...@gmail.com> on 2005/04/01 19:44:29 UTC

Indirect jsp:include does not seem to work

Hello all,

I have master jsp page, and I try to jsp:include
page="/strutsAction.do", which forwards to detail jsp page,
but this does not work. On Tomcat 4.x and 5.x the detail
page content is included, but further content from the
master page is stripped out.

According to jsp specs, if I include a resource with
jsp:include, its content should be included in the page.
Afaik the spec does not specify nesting level.

I looked in the code. ApplicationDispatcher correctly
identifies the first request to strutsAction.do as "Path
Based Include". But when struts action forwards to detail
jsp, ApplicationDispatcher identifies it as "Path Based
Forward". doForward() is called instead of doInclude(), and
ApplicationDispatcher flushes and closes the response
writer. Thus, Jasper cannot write the rest of master page
content to writer, and throws
"org.apache.jasper.JasperException: Stream closed".

Without thinking much, I commented out writer flushing in
ApplicationDispatcher.doForward(). It seems to work on
Tomcat 4.1.31, but failed on Tomcat 5.0. Anyway, I am not
sure that I did a right thing and that all buffers are properly being
closed now. Would be great if Tomcat devs look into it.

Btw, Jetty does not work as I want, too. BUT: I tried to create a
"proxy" JSP page, which is included in main JSP page. This proxy page
includes strutsAction.do, which forwards to real JSP page that I want
to include (whew!) Jetty works perfectly fine with this proxy JSP
page!

Also, Resin works fine both with direct including of struts action
from main page, and with proxy JSP page.

So, I believe that this is a Tomcat bug.

Thanks,
   Michael Jouravlev.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Indirect jsp:include does not seem to work

Posted by "Ian F. Darwin" <ia...@darwinsys.com>.
Now I understand: you want real life to work like the comic book! :-) :-)

(Don't take that personally, it's April 1 today after all).



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Indirect jsp:include does not seem to work

Posted by "Michael J." <jm...@gmail.com>.
> A syntax reference is not the same as a specification. Specifications
> are (supposedly) more rigorous and
> more precise in their specification of required behaviour. Tomcat is the
> reference implementation
> for the Servlet and JSP specifications.  It might be helpful if
> everybody who is interested in this
> discussion could please read [spec list skipped]

I will read the specs, but I am having a deja vu: California Driver's
Handbook is for drivers, who don't know how to drive anyway. It is
just a funny comics pamphlet. California Vehicle Code is a real thing
for cops, and contains all the proper rules.

> <spec-quote version="2.4" section="8.4">
> Before the forward method of the RequestDispatcher interface returns, the
> response content must be sent and committed, and closed by the servlet
> container.
> </spec-quote>

Frankly speaking, as a user I don't care about dispatchers, responses
and containers. I just want to include a _resource_, which is allowed
according to Sun's "quick reference card" for JSP 1.2. Ok, Sun
apparently is screwed up, mixing the requirements, but it should not
be my problem, because its syntax reference card works for me :) I
want my problem to be solved. And this works in other containers. I
understand that Tomcat has to go by the real spec, not by the comics
book. Then, in this case spec should be updated.

This functionality is important to me. And currently I cannot
implement it on Tomcat without a... er... "patch", which I did myself
and which can break something else. So I would prefer a real fix from
Tomcat pros.

> The language for the 2.3 spec is similar.  Bottom line: Resin is wrong ;-).

Wrong or not, it works great for me.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Indirect jsp:include does not seem to work

Posted by "Ian F. Darwin" <ia...@darwinsys.com>.
Michael J. wrote:

>Here is what I found at:
>http://java.sun.com/products/jsp/syntax/1.2/syntaxref1214.html#8828
>[snip]
>So, what I am doing is perfectly legitimate...
>  
>
A syntax reference is not the same as a specification. Specifications 
are (supposedly) more rigorous and
more precise in their specification of required behaviour. Tomcat is the 
reference implementation
for the Servlet and JSP specifications.  It might be helpful if 
everybody who is interested in this
discussion could please read JSP4.5 (section 4.5 of the JSP spec, 
version 1.2, since you are talking about Tomcat 4). See also SRV.8, that 
is, section 8 of the Servlet spec (Version 2.3, for Tomcat 4), which 
defines how the underlying include and forward mechanisms work; pay 
particular attention to sections 8.3 and 8.4 (compare the first lines of 
each of those sections).

>Resin works exactly as I expect, and Jetty works too with a proxy JSP
>page. I have not tried other servers yet.
>  
>
I have experienced this error too, and I wish Tomcat worked that way, 
but I haven't yet found
anything in the Specifications that would allow me to change how it 
works :-)   As implied by the
spec, there may be different results depending on the sizes of buffers 
used by the implementation.

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Indirect jsp:include does not seem to work

Posted by Bill Barker <wb...@wilshire.com>.
<spec-quote version="2.4" section="8.4">
Before the forward method of the RequestDispatcher interface returns, the
response content must be sent and committed, and closed by the servlet
container.
</spec-quote>

The language for the 2.3 spec is similar.  Bottom line: Resin is wrong ;-).

----- Original Message -----
From: "Michael J." <jm...@gmail.com>
To: "Tomcat Developers List" <to...@jakarta.apache.org>
Sent: Friday, April 01, 2005 10:51 AM
Subject: Re: Indirect jsp:include does not seem to work


> Here is what I found at:
> http://java.sun.com/products/jsp/syntax/1.2/syntaxref1214.html#8828
>
> "The <jsp:include> element allows you to include either a static or
> dynamic resource in a JSP page. The results of including static and
> dynamic resources are quite different. If the resource is static, its
> content is included in the calling JSP page. If the resource is
> dynamic, it acts on a request and sends back a result that is included
> in the JSP page. When the include action is finished, the JSP
> container continues processing the remainder of the JSP page."
>
> So, what I am doing is perfectly legitimate. I include a dynamic
> resource (spec does not clarify the type of "resource" or its nesting
> level). It should return result, to be included in the main page. And
> "JSP container continues processing the remainder of the JSP page",
> which Tomcat does not do. It is a bug.
>
> Resin works exactly as I expect, and Jetty works too with a proxy JSP
> page. I have not tried other servers yet.
>
> Thank you,
>    Michael.
>
> On Apr 1, 2005 10:39 AM, Tim Funk <fu...@joedog.org> wrote:
> > You cannot perform a forward inside an include. [Just like you can't set
any
> > headers, including cookies,  in an include or a host of other things
while in
> > an include.]
> >
> > -Tim
> >
> > Michael J. wrote:
> >
> > > Hello all,
> > >
> > > I have master jsp page, and I try to jsp:include
> > > page="/strutsAction.do", which forwards to detail jsp page,
> > > but this does not work. On Tomcat 4.x and 5.x the detail
> > > page content is included, but further content from the
> > > master page is stripped out.
> > >
> > > According to jsp specs, if I include a resource with
> > > jsp:include, its content should be included in the page.
> > > Afaik the spec does not specify nesting level.
> > >
> > > I looked in the code. ApplicationDispatcher correctly
> > > identifies the first request to strutsAction.do as "Path
> > > Based Include". But when struts action forwards to detail
> > > jsp, ApplicationDispatcher identifies it as "Path Based
> > > Forward". doForward() is called instead of doInclude(), and
> > > ApplicationDispatcher flushes and closes the response
> > > writer. Thus, Jasper cannot write the rest of master page
> > > content to writer, and throws
> > > "org.apache.jasper.JasperException: Stream closed".
> > >
> > > Without thinking much, I commented out writer flushing in
> > > ApplicationDispatcher.doForward(). It seems to work on
> > > Tomcat 4.1.31, but failed on Tomcat 5.0. Anyway, I am not
> > > sure that I did a right thing and that all buffers are properly being
> > > closed now. Would be great if Tomcat devs look into it.
> > >
> > > Btw, Jetty does not work as I want, too. BUT: I tried to create a
> > > "proxy" JSP page, which is included in main JSP page. This proxy page
> > > includes strutsAction.do, which forwards to real JSP page that I want
> > > to include (whew!) Jetty works perfectly fine with this proxy JSP
> > > page!
> > >
> > > Also, Resin works fine both with direct including of struts action
> > > from main page, and with proxy JSP page.
> > >
> > > So, I believe that this is a Tomcat bug.
> > >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
>
>



This message is intended only for the use of the person(s) listed above as the intended recipient(s), and may contain information that is PRIVILEGED and CONFIDENTIAL.  If you are not an intended recipient, you may not read, copy, or distribute this message or any attachment. If you received this communication in error, please notify us immediately by e-mail and then delete all copies of this message and any attachments.

In addition you should be aware that ordinary (unencrypted) e-mail sent through the Internet is not secure. Do not send confidential or sensitive information, such as social security numbers, account numbers, personal identification numbers and passwords, to us via ordinary (unencrypted) e-mail.



Re: Indirect jsp:include does not seem to work

Posted by "Michael J." <jm...@gmail.com>.
Here is what I found at:
http://java.sun.com/products/jsp/syntax/1.2/syntaxref1214.html#8828

"The <jsp:include> element allows you to include either a static or
dynamic resource in a JSP page. The results of including static and
dynamic resources are quite different. If the resource is static, its
content is included in the calling JSP page. If the resource is
dynamic, it acts on a request and sends back a result that is included
in the JSP page. When the include action is finished, the JSP
container continues processing the remainder of the JSP page."

So, what I am doing is perfectly legitimate. I include a dynamic
resource (spec does not clarify the type of "resource" or its nesting
level). It should return result, to be included in the main page. And
"JSP container continues processing the remainder of the JSP page",
which Tomcat does not do. It is a bug.

Resin works exactly as I expect, and Jetty works too with a proxy JSP
page. I have not tried other servers yet.

Thank you,
   Michael.

On Apr 1, 2005 10:39 AM, Tim Funk <fu...@joedog.org> wrote:
> You cannot perform a forward inside an include. [Just like you can't set any
> headers, including cookies,  in an include or a host of other things while in
> an include.]
> 
> -Tim
> 
> Michael J. wrote:
> 
> > Hello all,
> >
> > I have master jsp page, and I try to jsp:include
> > page="/strutsAction.do", which forwards to detail jsp page,
> > but this does not work. On Tomcat 4.x and 5.x the detail
> > page content is included, but further content from the
> > master page is stripped out.
> >
> > According to jsp specs, if I include a resource with
> > jsp:include, its content should be included in the page.
> > Afaik the spec does not specify nesting level.
> >
> > I looked in the code. ApplicationDispatcher correctly
> > identifies the first request to strutsAction.do as "Path
> > Based Include". But when struts action forwards to detail
> > jsp, ApplicationDispatcher identifies it as "Path Based
> > Forward". doForward() is called instead of doInclude(), and
> > ApplicationDispatcher flushes and closes the response
> > writer. Thus, Jasper cannot write the rest of master page
> > content to writer, and throws
> > "org.apache.jasper.JasperException: Stream closed".
> >
> > Without thinking much, I commented out writer flushing in
> > ApplicationDispatcher.doForward(). It seems to work on
> > Tomcat 4.1.31, but failed on Tomcat 5.0. Anyway, I am not
> > sure that I did a right thing and that all buffers are properly being
> > closed now. Would be great if Tomcat devs look into it.
> >
> > Btw, Jetty does not work as I want, too. BUT: I tried to create a
> > "proxy" JSP page, which is included in main JSP page. This proxy page
> > includes strutsAction.do, which forwards to real JSP page that I want
> > to include (whew!) Jetty works perfectly fine with this proxy JSP
> > page!
> >
> > Also, Resin works fine both with direct including of struts action
> > from main page, and with proxy JSP page.
> >
> > So, I believe that this is a Tomcat bug.
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org
> 
>

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org


Re: Indirect jsp:include does not seem to work

Posted by Tim Funk <fu...@joedog.org>.
You cannot perform a forward inside an include. [Just like you can't set any 
headers, including cookies,  in an include or a host of other things while in 
an include.]

-Tim

Michael J. wrote:

> Hello all,
> 
> I have master jsp page, and I try to jsp:include
> page="/strutsAction.do", which forwards to detail jsp page,
> but this does not work. On Tomcat 4.x and 5.x the detail
> page content is included, but further content from the
> master page is stripped out.
> 
> According to jsp specs, if I include a resource with
> jsp:include, its content should be included in the page.
> Afaik the spec does not specify nesting level.
> 
> I looked in the code. ApplicationDispatcher correctly
> identifies the first request to strutsAction.do as "Path
> Based Include". But when struts action forwards to detail
> jsp, ApplicationDispatcher identifies it as "Path Based
> Forward". doForward() is called instead of doInclude(), and
> ApplicationDispatcher flushes and closes the response
> writer. Thus, Jasper cannot write the rest of master page
> content to writer, and throws
> "org.apache.jasper.JasperException: Stream closed".
> 
> Without thinking much, I commented out writer flushing in
> ApplicationDispatcher.doForward(). It seems to work on
> Tomcat 4.1.31, but failed on Tomcat 5.0. Anyway, I am not
> sure that I did a right thing and that all buffers are properly being
> closed now. Would be great if Tomcat devs look into it.
> 
> Btw, Jetty does not work as I want, too. BUT: I tried to create a
> "proxy" JSP page, which is included in main JSP page. This proxy page
> includes strutsAction.do, which forwards to real JSP page that I want
> to include (whew!) Jetty works perfectly fine with this proxy JSP
> page!
> 
> Also, Resin works fine both with direct including of struts action
> from main page, and with proxy JSP page.
> 
> So, I believe that this is a Tomcat bug.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org