tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Root <bradford.r...@gmail.com>
Subject Behavior change to JspWriterImpl in 7.0.24
Date Fri, 21 Sep 2012 21:14:16 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message