tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Kumanan Rajamanikkam <KRajamanik...@DoughNET.com>
Subject Re: JSP with taglibs -- output in wrong order without flush?
Date Thu, 03 Aug 2000 00:35:32 GMT
Serge,

In my project Most of our JSP's have both <jsp:include> and <jsp:forward>
like for example

<jsp:include page="/xyz.jsp" flush="true"/>
<% if ( i > 100 ) { %>
<jsp:forward page="/displayaccounts.jsp"/>
<% } %>

This code works in JRun2.3.3. But gives the following error in Tomcat. 
	javax.servlet.ServletException: Error: Attempt to clear a buffer
that's already been flushed 

I know this is the expected behaviour according to specs which mandates
flush="true". To get around this problem I tried 
changing the jsp's using RequestDispatcher's include and forward methods.
This gives output in wrong order. Is there anything
I can do to make this work ?

I really appreciate your answer regarding this as we are having a tough time
porting to Tomcat because of this problem.

Thanks
Kumanan

> Michael,

> I'm guessing the problem is with how you're accessing the writer.  If
> you do something like pageContext.getRequest().getWriter() (you might
> have to cast, don't remember exactly), you're in fact creating a new
> JspWriter instance.  What you should do is use the bodyOut/bodyContent
> (whatever you're calling it locally) and call getEnclosingWriter(). 
> This will give you the JspWriter that the JSP was using directly. 
> Otherwise you write to the new writer instance, which then will cause
> order problems as you describe.  Check over some of the examples to see
> how this is done.

> Serge Knystautas
> Loki Technologies
> <http://www.lokitech.com/>

Michael Taylor wrote:
> 
> I have a project where I am using taglibs to hide complexity in a JSP
page.  If
> I include another page into the JSP within this tag, I find that the
output
> comes out in the wrong order.
> 
> The included content is put into the output BEFORE the preceding JSP code.
For
> example:
> 
> <html><head><title>Example</title></head>
> <body>
> <foo:mytag />
> </body>
> </html>
> 
> When I did this, I got the included text, followed by all the other text.
Now,
> if within my tag, I call upon the writer and flush() the output then the
output
> appears in the correct order.
> 
> When I did a BodyTag, with included content for both the start and end tag
I
> had far worse results.
> 
> In all cases, adding flush() calls solved the problem.
> 
> Is this a bug, or something I am not understanding?
> 
> Thanks in advance,
> 
> Mike
> 
>   --
> Michael Taylor, mtaylor@emeraldcave.net
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message