tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Chaffee <>
Subject BUG: flushBuffer in Jasper
Date Fri, 25 Aug 2000 15:46:08 GMT
I fixed the bug (BugRat #14) where out.flush() and
response.flushBuffer() don't actually flush.  This was a spec-breaker.

There's still a problem (spec-breaking) with Jasper's
response.flushBuffer() but I'm not sure how to fix it.  Please give me

(Note that in a JSP, out.flush() does the right thing now, but
response.flushBuffer() does not.)

The problem comes because Jasper JspWriter has its own buffer --
apparently this was written before Costin added OutputBuffer to the
servlet output stream.  But the Response object used by Jasper is the
exact same one that Tomcat passes it.  Unfortunately, this response
object has no idea of the existence of Jasper's JspWriter buffer.
Thus, its flushBuffer() method just flushes the Tomcat stream, not the
Jasper stream, and characters remain in Jasper until the response is

Possible solutions:

1. Remove the buffer from JspWriter.  This would be cleanest, but may
cause problems, since this kind of surgery would require modifying
lots of code throughout JspWriterImpl, possibly leading to odd bugs,
or at least a lot of work.  Also, I haven't thought through the
implications viz the autoFlush attribute, though on first blush I
don't think it would be a problem (we'd just say "Jasper is a
buffering JSP engine" which it actually already is).

2. Make Jasper implement a facade over Response (actually over
HttpServletResponse) that correctly implements flushBuffer by calling
jspwriter.flush(); this would have to be done inside _jspService,
meaning inside generated code, which seems flakey to me.  Also, a
trivial implementation of such a facade would lead to performance
issues (making a few new objects per JSP request), unless we use
pooling, which seems also like a lot of work.

3. Add a private callback method to our HttpServletResponse (in our
facade manager, called from to make the
HttpServletResponse facade) that calls Jasper when flushBuffer is
called; this would break compatibility with other servlet engines.

I'm leaning towards #1.  Any doubts?

 - Alex

Alex Chaffee             
jGuru - Java News and FAQs
Creator of Gamelan       
Founder of Purple Technology
Curator of Stinky Art Collective

View raw message