You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Harden ZHU <ha...@sympatico.ca> on 2001/11/13 09:31:38 UTC
PageContext.include and flush
JSP will do flush when call PageContext.include even make autoflush=false.
So how can I call include or any similar function like include without
flush? Since in that include page, I have error checkings. If have errors,
then will forward to some pages.
Once JSP flushed, I can't do forward any more. Or any solution for that?
Thanks
Harden
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: PageContext.include and flush
Posted by Rickard Öberg <ri...@xpedio.com>.
Craig R. McClanahan wrote:
>>So how can I call include or any similar function like include without
>>flush? Since in that include page, I have error checkings. If have errors,
>>then will forward to some pages.
>>Once JSP flushed, I can't do forward any more. Or any solution for that?
>>
>>
>
> I'd suggest an approach based on what the generated code created by Jasper
> does to implement <jsp:include ... flush="false"/>. It calls a utility
> method to wrap the current JspWriter() in a response, and uses
> RequestDispatcher.include() to execute the included resource. As a
> result, the output is buffered to the current writer and the response is
> not committed.
But, as has been previously discussed (see archives), note that this
will more or less only work on Tomcat4, since other servlet engines call
getServletOutputStream instead. The portable solution is "a bit" nastier
than what Craig outlines above.
/Rickard
--
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: PageContext.include and flush
Posted by "Craig R. McClanahan" <cr...@apache.org>.
On Tue, 13 Nov 2001, Harden ZHU wrote:
> Date: Tue, 13 Nov 2001 03:31:38 -0500
> From: Harden ZHU <ha...@sympatico.ca>
> Reply-To: Tomcat Developers List <to...@jakarta.apache.org>
> To: Tomcat Developers List <to...@jakarta.apache.org>
> Subject: PageContext.include and flush
>
> JSP will do flush when call PageContext.include even make autoflush=false.
That's because of a statement in the Javadocs of PageContext.include()
that requires this behavior.
> So how can I call include or any similar function like include without
> flush? Since in that include page, I have error checkings. If have errors,
> then will forward to some pages.
> Once JSP flushed, I can't do forward any more. Or any solution for that?
>
I'd suggest an approach based on what the generated code created by Jasper
does to implement <jsp:include ... flush="false"/>. It calls a utility
method to wrap the current JspWriter() in a response, and uses
RequestDispatcher.include() to execute the included resource. As a
result, the output is buffered to the current writer and the response is
not committed.
The runtime code that does this is the include() method of the
"org.apache.jasper.runtime.JspRuntimeLibrary" class, which you can get by
downloading the source version of Tomcat 4, or browse it in the online CVS
browser at the Jakarta web site.
> Thanks
>
> Harden
>
Craig
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>