On Thu, Sep 12, 2013 at 11:06 AM, Christopher Schultz < ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > Shanti, > > > > I think you are confused about a few things. Flushing the stream does > not close it, but the finalizer I believe also closes the stream as > well. Tomcat may not allow the stream to actually be closed (because > Tomcat wants the stream to say open... at least the "stream" object > that it presents to servlets), so the close() does nothing. The > flush(), however, still occurs. > > Flushing the OutputStream of a response "commits" the response -- > meaning that the bytes are actually sent to the client. If that > happens (remember: ImageIO is interfering with a "later" and unrelated > request to the image-related one) than the later request -- still > in-process -- might not have expected that response-commit and things > like request.getSession() can fail because those calls must be made > before the response has been sent to the client (because creating the > JSESSIONID cookie requires setting a response header). > > Hope that helps, > - -chris > > Thanks for the explanation, Chris. That's now clear to me. Appreciate it! -Shanti