-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Michael,
Michael Ludwig wrote: > So the output of S gets collected by WR and is now available to F. And F > calls getWriter() on the original response, and this to my surprise > triggers an IllegalStateException: > > getOutputStream() has already been called for this response > > But I haven't called getOutputStream() - I've called getWriter(). Yes, but your included resource probably called getOutputStream. You should really override getOutputStream as well as getWriter in your HttpServletResponseWrapper. > So is it the recommended approach in this sort of scenario (or contrived > example) to proceed as observed in the DefaultServlet, by first trying > one of SOS and PW, catch the exception and then try the other one? Unfortunately, I don't know if a way to check to see which of getOutputStream/getWriter was called, so you might have to do this. > So how can I implement getOutputStream() to substitute a buffer? Does > anyone have an implementation? How are you doing this with getWriter? With a StringWriter? Maybe you want to look at java.io.ByteArrayOutputStream. > But even with my Filter overriding both getOutputStream() and > getWriter() and substituting buffers that will be written to, there is a > problem. Servlet S will write to one buffer, and the DefaultServlet will > write to another one. The place of the include set in the source code of > S will be lost. Is this analysis correct? Mostly. What you need to do is provide a unified buffer that /both/ calls can write to. If you use a ByteArrayOutputStream at the lowest level and then wrap that in an OutputStreamWriter for calls to getWriter(), you should be able to handle arbitrary use of your wrapper. Hope that helps, - -chris -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (MingW32) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iEYEARECAAYFAkkbMoAACgkQ9CaO5/Lv0PCa9QCeMVLbd4dHVE6NwRHI9U2hAdM3 gxkAnR/zKPYvM8hQWSoKzGdrDoOsUC7q =zT3d -----END PGP SIGNATURE----- --------------------------------------------------------------------- To start a new topic, e-mail: users@tomcat.apache.org To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]