tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Vincent Chain <>
Subject Servlet Response Wrapper not able to get JSP data: how to control flush?
Date Mon, 24 Nov 2003 06:11:31 GMT
I thought I should not be the only one with this issue, but I searched the tomcat-user and
tomcat-dev mailing lists and could not find a good answer. There are some changes made between
tomcat4.0.4 and tomcat4.1.18 and I can see the exact discussions on the tomcat-dev list (under
the thread "Costin: reverted the fix"), but I did not see an answer to as how this should
work. Forgive me if I missed some obvious answers. Here is my issue
I have a Servlet 2.3 filter that encodes all jsp output. It works fine in tomcat 4.0.4 and
not any more if I move to tomcat 4.1.18 (I did not try earlier 4.1.x versions though, I tried
4.1.29 and the problem remains). My filter does this in a very typical way:
* before calling filterchain.doFilter it creates a response wrapper
* the response wrapper will return a outpustream/writer wrapper for wrapped servlet/jsp to
* after filterchain.doFilter returns, the filter gets data out and do the encoding. then it
writes the encoded data to the 'real' response (the response passed to it)
The problem is the implementation of PageContextImpl.release() has changed. Previously it
will call flush() but now it calls flushBuffer(). the latter does not flush data to my OutputStream/Writer
wrapper so when the filterchain.doFilter returns from the jsp service, I could not get the
result of the jsp. I could not get handle of the JspWriter that was used in the jsp page to
force a flush since that is not in my scope. 
I could surely add a 
in every jsp i wrote, but that seems too ugly to me, and it does not feel quite right either.
Here is the comment put into PageContextImp.release()
                // Do not flush the buffer even if we're not included (i.e.
                // we are the main page. The servlet will flush it and close
                // the stream.
However, since my fitler don't reference the jsp servlet I don't see how I could force the
flush and close the stream. I see a followup email talking about 
* automatically generating out.flush at the end of the java code for a jsp
* implement a partial flush
And I could not see anything following up that.
I read the Sun servlet spec, and I could not see a clear definition on this. It seems with
the wrapper, the sense of 'commit' is not what it meant to be previously: in this case, I
do want the data to be flushed (committed) but it has nothing to do with flushing data to
the end user.
I tried some popular CompressionFilter implementations and they fail on tomcat4.1.18 for the
same reasons. So what is the recommendation?
Thanks a lot

Do you Yahoo!?
Free Pop-Up Blocker - Get it now
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message