tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Speed <psp...@progeeks.com>
Subject Re: JSP with taglibs -- output in wrong order without flush?
Date Wed, 26 Jul 2000 15:29:23 GMT


Serge Knystautas wrote:
> 
> Michael Taylor wrote:
> > The spec that said that it was illegal to use <jsp:include> in a context
> > where 'out' was not the current writer, or something like that.  I think
> > this means that it's illegal to use <jsp:include> within the body of a
> > tag.  The spec claims this is because there is no backing stream behind
> > the body of this tag, which makes sense.  It's my guess that
> > <jsp:include> always writes to the top-level writer directly.
> 
> I'm pretty sure this is the case for the reasons you give.  I'd like a
> way around that though in the next version of the servlet API. ;)
> 
> > This may have something to do with my problem.  I am calling
> > RequestDispatcher to include pages from my start and end tags and I know
> > this is exactly equivalent to what <jsp:include> does.  Specifically I
> > have the following type of code:
> 
> I actually wrote a tag for my own purposes this week that does include
> and forward from within a tag.  It works, but what I did was use the
> include(String relativeURI) method on the PageContext object.  I'm
> assuming this was added specifically for this purpose
> (including/forwarding from a tag library).  I'm happy to say it works
> better than I had hoped (i was expecting it to give an
> IllegalStateException or something like that), although I do have to
> call flush in the doStartTag() method (actually, I call clearBuffer
> because of the tag's use, but that's irrelevant... I was still having
> flushing problems).  I actually do the include in the doAfterBody()
> method, so I assume if it can include another JSP there, it can do it in
> any method.
> 

	The problem I had with your specific approach was that the
tag bodies were output after the include.  If my include tag was 
within several nested tags this got very strange.

	I ended up traversing up the body stack collecting the 
content so that I could output it before calling the flush.  
Clearing the body content object at each level keeps it from being
printed twice.  It's less than ideal but it was the only thing I 
could get working on the late night I did it! :)

	-Paul (pspeed@progeeks.com)

Mime
View raw message