tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Hartung" <>
Subject Filters and content size.
Date Thu, 10 Nov 2005 03:03:12 GMT
First a simple question.

Do Tomcat, or servlet containers in general, set the Content-Size header for
dynamic content?

Specifically, do the containers typically buffer all generated content in
order to get the content size before sending the response, or will it just
stream it out ad hoc?

Is Content-Size required? (I sort of think it is, but I'm not sure.)

Anyway, the reason I ask is that I want to write a Filter that does some
translation and replacement. If I can, I want to make it a streaming filter
with a custom Response and stream so I don't have to buffer the entire page,
translate it, and then dump it out. To save memory if nothing else.

But I assume that if Tomcat is buffering the response as well, then the
ServletOutputStream I get from the original Response will be filling that
buffer, and then setting the Content-Size for me.

Otherwise, if *I* am required to set that value, then I need to buffer the
whole thing and dump it all at once.

Is the behavior different if I use the ServletOutputStream vs the
PrintWriter? Say, PrintWriter buffers and sets Content-Length for me, but
ServletOutputStream does not?

Any hints here?



Will Hartung

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message