Including in a JSP the result of a servlet that forwards

2007-11-28 Thread Antonio Petrelli
Hi all,
If I make a jsp:include (in fact I am using Tiles, but the result is
the same) of a result of a servlet which, in turn, makes an
ApplicationDispatcher.forward, I have a strange effect:
- only the page forwarded by the servlet will be visible to the user;
- the rest of the JSP page is executed, but it gives a Stream closed error.
I tested on Tomcat 5.5.25 and Jetty 6.1.1rc1 (embedded in Cargo, Maven
2 plugin), that (correct me if I am wrong) shares the Jasper engine
with Tomcat.
Independently from the fact if it is a good or a bad idea to forward
into a servlet that is included, is this the normal behaviour or is it
a bug?

Thanks in advance
Antonio

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Including in a JSP the result of a servlet that forwards

2007-11-28 Thread Martin Gainty
Hi Antonio-

https://java.sun.com/products/servlet/2.1/api/javax.servlet.RequestDispatche
r.html#forward(javax.servlet.ServletRequest,%20javax.servlet.ServletResponse
)
where the most relevant part is This method may not be used if the calling
servlet has already output any response to the client.
decide which servlet is constructing the response and forward to that
servlet

Anyone?
Martin--
- Original Message -
From: Antonio Petrelli [EMAIL PROTECTED]
To: users@tomcat.apache.org
Sent: Wednesday, November 28, 2007 6:41 AM
Subject: Including in a JSP the result of a servlet that forwards


 Hi all,
 If I make a jsp:include (in fact I am using Tiles, but the result is
 the same) of a result of a servlet which, in turn, makes an
 ApplicationDispatcher.forward, I have a strange effect:
 - only the page forwarded by the servlet will be visible to the user;
 - the rest of the JSP page is executed, but it gives a Stream closed
error.
 I tested on Tomcat 5.5.25 and Jetty 6.1.1rc1 (embedded in Cargo, Maven
 2 plugin), that (correct me if I am wrong) shares the Jasper engine
 with Tomcat.
 Independently from the fact if it is a good or a bad idea to forward
 into a servlet that is included, is this the normal behaviour or is it
 a bug?

 Thanks in advance
 Antonio

 -
 To start a new topic, e-mail: users@tomcat.apache.org
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: Including in a JSP the result of a servlet that forwards

2007-11-28 Thread Antonio Petrelli
2007/11/28, Martin Gainty [EMAIL PROTECTED]:
 Hi Antonio-

 https://java.sun.com/products/servlet/2.1/api/javax.servlet.RequestDispatche
 r.html#forward(javax.servlet.ServletRequest,%20javax.servlet.ServletResponse
 )
 where the most relevant part is This method may not be used if the calling
 servlet has already output any response to the client.
 decide which servlet is constructing the response and forward to that
 servlet

In the 2.4 version of the servlet we have:
http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/RequestDispatcher.html#forward(javax.servlet.ServletRequest,%20javax.servlet.ServletResponse)
where the relevant (for me) is:

snip
forward should be called before the response has been   committed to
the client (before response body output has been flushed).If the
response already has been committed, this method throws  an
IllegalStateException.  Uncommitted output in the response buffer is
automatically cleared   before the forward.
/snip

But response.isCommitted returns false (!), the implementation is
ServletResponseWrapperInclude:
http://tomcat.apache.org/tomcat-5.5-doc/jasper/docs/api/org/apache/jasper/runtime/ServletResponseWrapperInclude.html
And I don't see any IllegalStateException.

So I now ask, is there a way to know if I can forward or not?

Thanks
Antonio

-
To start a new topic, e-mail: users@tomcat.apache.org
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]