tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jan Luehe <Jan.Lu...@Sun.COM>
Subject Re: Possible javax.servlet.http.HttpServlet bugs, and where to report them?
Date Thu, 25 Jan 2007 19:18:18 GMT
Hi Mike,

 > I think there's a bug in javax.servlet.http.HttpServlet, but I'm not 
sure where to report it.
 > I'm posting this here for the time being (and possibly on the 
Glassfish "issue tracker" if and
 > when I can jump through the hoops required to do so), but please let 
me know if it ought to be
 > reported some other way: and apologies if this doesn't belong here!

I found another problem with HttpServlet's NoBodyOutputStream: If you use
getWriter(), the returned writer is constructed as follows:

    OutputStreamWriter w = new OutputStreamWriter(
        noBody, getCharacterEncoding());
    writer = new PrintWriter(w);

Notice that when you wrap an OutputStreamWriter around noBody, the
output will be buffered by the OutputStreamWriter before it is written
to "noBody", meaning that when NoBodyOutputStream.setContentLength()
is called, noBody.getContentLength() will return 0 if the output is still
buffered. Therefore, NoBodyOutputStream.setContentLength() needs to
flush the writer (if one is being used) before calling 
as follows:

    void setContentLength() {
        if (!didSetContentLength) {
            // BEGIN PATCH
            if (writer != null) {
            // END PATCH

Let me know what you think.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message