tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bart Locanthi <b...@sabl.com>
Subject PageContext.pushWriter(JspWriter)
Date Sat, 02 Feb 2002 22:25:25 GMT
After hitting my head against the wall that is PageContext.pushBody() 
and it's near-uselessness, I have finally hacked my Tomcat 4.0.1 and 
added one measly method to the servlet API.

And boy is my life getting better fast.

The issues are twofold:

1) pushBody() makes a BodyContent for you, pushes it, and returns it. 
This does nothing for folks who want to put some other sort of Writer in 
place, like say a PipedJspWriter to be fed from an XSLT Thread, or whatever.

2) even if pushBody() did what you want, it's pointless to invoke it 
from a Tag, since the JSP compiler won't set the "out" variable used to 
send static content etc.

So I have humbly - humbly! - added pushWriter(JspWriter) to the API and 
altered tomcat's TagBeginGenerator and TagEndGenerator to say

	out = pageContext.getOut()

when a BodyTag *doesn't* return EVAL_BODY_BUFFERED, and voila I finally 
have what I've been needing all this time. Now I can stream between Tags 
and take another, more general, and simpler crack at taglibs/io. And 
static HTML content just works, and Tags don't have to conspire with 
each other or mess with global state. And more, but that's for another post.

I don't know the JSP standards process, but I'm hoping whoever is in 
charge will take this modification and the reasoning behind it under 
serious consideration.

The attached patches are against jakarta-servletapi-4 as downloaded from 
the current CVS, and for jakarta-tomcat-4.0.1-src (the CVS for 
tomcat-4.0 seems to be older, and I didn't find a more current one).

Oh, the tomcat patch also includes a fix for TagCache that is more 
definite about finding setters for Tag attributes. So you can use 
"class=" now and get more predictable behavior for attributes in 
general. Apologies for mixing them.

Mime
View raw message