Why does the ResponseUtils.writePrevious method do this?

        JspWriter writer = pageContext.getOut();
        while (writer instanceof BodyContent)
            writer = ((BodyContent) writer).getEnclosingWriter();


Isn't the whole point of the BodyContent to allow doAfterBody() to decide
when and if to keep the output generated by the tag's body?  

It seems to me that a nested bodytag should always output to its parent's
BodyContext, not the page level writer or anything in between.  If it
doesn't, the child bodytag bypasses the parent bodytag's ability to control
its body.

And it also seems like text could get written to the response out of order.
Have a look at the following JSP fragment.  

<foo:bar1>
    some bar1 template text
    <foo:bar2>
         bar2 template text
    </foo:bar2>
    some more bar1 template text
</foo:bar1>

If bar2.doAfterBody writes directly to the page level writer, wouldn't the
output be:

       bar2 template text
    some bar1 template text
    some more bar1 template text

Am I completely out of my mind here or what?  (I've not tested any of this.)

-Robert Quillen

Reply via email to