tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tek1 <t...@pobox.com>
Subject Re: retrieving HttpSession in Filter? ServletResponse.setContentLength()?
Date Wed, 21 Aug 2002 16:52:28 GMT
hi charlies and craig.  thanks for your replies.



At 08:21 02/08/19 -0700, you wrote:

>If your filter is calling response.setContentLength() -- or any other
>header setting method, such as trying to add a cookie -- after the
>response has been committed, then this attempt to set the header will get
>ignored just like it would if your original servlet had done so.
>
>If you have a post-processing filter that can change the content length of
>the response, you are going to need to write a response wrapper that:
>* Buffers up the output from the servlet into either memory or a
>   temporary file
>* After the real servlet completes, do whatever modifications
>   are needed, calls setContentLength() on the real response, and
>   then copies the modified output data to the real response.

the latter (ResponseWrapper) is exactly what i am using.  basically, the 
same thing as the CharResponseWrapper described in:

http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/Servlets8.html#82361

i tried calling response.setContentLength() on the *real* response in my 
filter *before* the response is sent to the (mobile) java client, but the 
client isn't detecting that the content length has been set and hangs 
waiting.  however, when i set the content length in the servlet and not the 
filter, the client detects the content length (although the length doesn't 
account for the extra data needed to be added in the filter)...

right after calling setContentLength on the real response in my filter, is 
there any way to call something like getContentLength() on the response to 
confirm that it's being set?



>There was an example filter that did post-processing XSLT transformations
>on Java Developer Connection (at java.sun.com) a while back, which
>illustrated exactly this kind of processing.  In fact, the original
>version of the code in the article had exactly this sort of bug, and had
>to be corrected later :-).

do you happen to have the link to the article?  i followed sun's example 
filter using a CharResponseWrapper and my filter's not working...  :|

thanks again for helping.  i appreciate it.


--
To unsubscribe, e-mail:   <mailto:tomcat-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:tomcat-user-help@jakarta.apache.org>


Mime
View raw message