-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Dave,
On 4/29/2009 10:41 PM, Dave Cherkassky wrote: > 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... > > 2) So you are suggesting that writing out to the > response.getOutputStream() as I go is wrong? Instead, I need to: > a. buffer my output locally > b. once I am sure that it can all be created correctly, *then* I write > out the buffer to the response? The buffer isn't the problem, as Pid suggests. If it were, you'd be getting a different error (something like "Response already committed"). The problem is that your servlet calls response.getOutputStream() and your error page (a JSP) calls response.getWriter(). The servlet spec says this is a no-no, so you get this exception thrown. It's not really your fault per se, but that's what's happening. Do you have the option of generating your Excel document to memory (ByteArrayOutputStream) or a temporary file before streaming it to the client? That would be ideal, as you could wait until the entire document was generated before trying to send it (or any of the "Content-Type" headers, which would be helpful). If an error occurs, the user gets an error page instead of an error page disguised as an Excel document. If the document you generate is huge, and you *must* stream it, well, then, you just have to do a better job of error handling in your servlet, then. Just catch Throwable or RuntimeException or whatever and take appropriate action (whatever that means... maybe putting an error directly in the Excel file like "OMG something bad happened... file truncated"). - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAkn7VS8ACgkQ9CaO5/Lv0PAPVwCdGEsKrB1kTjAfngKtp0HDnO6s X9gAoKwLjyViqjF2FtSALiCsqjT/dvFa =iThm -----END PGP SIGNATURE----- --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org For additional commands, e-mail: users-h...@tomcat.apache.org