tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pid...@pidster.com>
Subject Re: Servlets that use response.getOutputStream(): do they play nicely with Tomcat's error pages?
Date Thu, 30 Apr 2009 11:13:33 GMT
Dave Cherkassky wrote:
> PID, thanks for your insight.
> 
> 
> Two comments about that:
> 
> 1) I agree with you for includes and forwards, but for errors?  I would
> have thought that the definition of "error" is that something went
> wrong, and Tomcat should start from scratch and just render the error
> page.  I didn't think of it as really a forward...

It can't start from scratch if you've already written to the output.
It would be like sending (pseudo)

>>snip>>

Status: 200 OK
Content-type: image/gif

2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf
2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf
2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf
2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf2020304msf0sfsfs0fsfsf
202004ladidaadidummlovelybytesUrk!CoughSplutterARGHH!Status: 500\n
Content-type: text/html\n
\n
<html>
etc

<<snip<<

The browser wouldn't understand that the new set of headers mid stream
actually represents an error.

> 2) So you are suggesting that writing out to the
> response.getOutputStream() as I go is wrong?  

If you are not already absolutely certain that the data is good, it's
risky at best.

> Instead, I need to:
> a. buffer my output locally

That would work.

> b. once I am sure that it can all be created correctly, *then* I write
> out the buffer to the response?
> 
> Am I understanding you correctly?

Yes.


p

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message