agreed if you put in log statements which include timings you may see some unplanned interleavings between methods i agree with the unified buffer but i would also make sure all your output methods are synchronized follow the advice on <String/Stream>Writers for incorporating charsets and implement encodings http://java.sun.com/j2se/1.4.2/docs/api/java/io/OutputStreamWriter.html
(pls keep us apprised of output as I would like to know how TC internals are manipulating the response) Viel Gluck Martin ______________________________________________ Disclaimer and confidentiality note Everything in this e-mail and any attachments relates to the official business of Sender. This transmission is of a confidential nature and Sender does not endorse distribution to any party other than intended recipient. Sender does not necessarily endorse content contained within this transmission. > Date: Fri, 21 Nov 2008 22:17:23 +0100 > From: [EMAIL PROTECTED] > To: users@tomcat.apache.org > Subject: Re: [Http]ServletResponseWrapper.getOutputStream() > > Christopher Schultz schrieb am 20.11.2008 um 10:05:48 (-0500): > > Micheal, > > > > Your comment about calling getResponse().getOutputStream() and > > ignoring the result got me to thinking... > > Christopher, > > I may actually have had a point there, although I'm not sure this is the > case. I just verified that the working HttpResponseCatcher I posted some > minutes ago stops working correctly when I omit the calls to the > underlying ServletResponse object. In that case, the output looks like > this: > > HTTP/1.1 200 OK > Server: Apache-Coyote/1.1 > Gurke: eingelegt > GuFilter-Zeichen: 101 > GuFilter-Oktette: 103 > Content-Type: text/html;charset=UTF-8 > Content-Length: 101 > Date: Fri, 21 Nov 2008 20:58:00 GMT > > <!-- Käseküchlein --><p>Included text</p> > <html><p>Before include</p> > <p>After include</p></html> > > You can see that the included HTML snippet is in the wrong place. (The > comment is inserted by the filter on the outgoing response.) > > > You know what? I just realized that I've been leading you down the > > wrong path: you must manage the buffers separately because of the "you > > can only call either getOutputStream OR getWriter" rule. > > > > I think you can still make it work with a unified buffer, but you have > > to be more careful. Let's be less careful and more straightforward. > > Your argument in favour of the unified buffer sounds perfectly logical > to me. In the end, it's all bytes that get written, regardless of > whether or not I wrap a PrintWriter around the buffer. > > I have to make sure, of course, to always hand out the same buffer, so > all output goes there. > > I possibly also have to make sure to play by the same rules as the real > implementation and not allow both getWriter() and getOutputStream() on > the same resonse. > > > Basically, you'll have to duplicate your efforts to wrap the Writer > > the same way you did the OutputStream: create a WriterWrapper and > > cache that information. I'd recommend using a StringWriter as a > > backing class, since you don't have to worry too much about the > > character encoding at that point (because Writers always use > > characters, not bytes). > > Hmm. Do you still think this is better? > > And what do you mean by "caching" it? Just keeping it in an instance > variable, instead of erroneously creating a new one for each call of > getWriter(), as I first did? > > > Anyhow, you definitely /should/ call getResponse().getOutputStream() > > (or getWriter(), whichever the case may be) when your getOutputStream() > > method is invoked: you definitely want the state handling to be done by > > the wrapped request, because you never know what has happened to the > > request before your filters gets its hands on it. > > I agree: You never know. And who knows what stuff gets set or tweaked in > Tomcat's internals for each one of getWriter() and getOutputStream(). On > the other hand, I haven't found any statement to the effect that you > have to pass through the calls to the underlying response object. > > Michael Ludwig > > --------------------------------------------------------------------- > To start a new topic, e-mail: users@tomcat.apache.org > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > _________________________________________________________________ Windows Live Hotmail now works up to 70% faster. http://windowslive.com/Explore/Hotmail?ocid=TXT_TAGLM_WL_hotmail_acq_faster_112008