You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Brad Root <br...@gmail.com> on 2012/09/21 23:14:16 UTC

Behavior change to JspWriterImpl in 7.0.24

Hi There,

Since Tomcat 7.0.24, I'm seeing a change in behavior when writing with the
JspWriterImpl class. This change has broken some of my existing custom tags.

Example 1 (in custom tag’s doTag() method):

getJspContext.getOut().write(“foo”);
RequestDispatcher rd = getRequest().getRequestDispatcher(“bar.jsp”) //
simple jsp, contains only “bar”
rd.include(getRequest(), getResponse())

Prior to 7.0.24, response output would be "foobar". Now, it's “barfoo”.


Example 2 (in custom tag’s doTag() method):


String longContent = getStringWithLengthGreaterThanBufferSize();
getJspContext.getOut().write(longContent);
RequestDispatcher rd = getRequest().getRequestDispatcher(“bar.jsp”) //
simple jsp, contains only “bar”
rd.include(getRequest(), getResponse())

Prior to 7.0.24, the entire longConent string would be flushed to the
stream prior to the dispatcher's include (e.g. "...foofoobar"). Now, I'm
seeing something like "...fbaroofoo").



Looking at the JSP spec, the behavior in 7.0.24 seems to be correct. I can
easily get the expected output by manually flushing JspWriterImpl's buffer
just after invoking the write() method:

if (getJspContext.getOut() instance of JspWriterImpl) {
    getJspContext.getOut().flush();
}



My question is this: Prior to 7.0.24, should I have been manually flushing
JspWriterImpl's buffer? Or did 7.0.24 introduce a new bug?

JspWriterImpl contains an OutputBuffer. The code change in 7.0.24 was an
optimization to OutputBuffer (
https://issues.apache.org/bugzilla/show_bug.cgi?id=52328), after which it is
no longer being flushed on every write.


Thanks,
Brad