I just finished up a caching filter, I ended up creating a DualServletOutputStream
that wrote both to the response and a ByteArrayBuffer, this gets lazy loaded when
getOutputStream() is called on the wrapper, else it will wrap the ptrintstream. You
will want to follow the same logic found in the GZip filter in 4.1.17+ I believe.
-Jacob
-----Original Message-----
From: Tim Funk [mailto:[EMAIL PROTECTED]]
Sent: Thu 1/30/2003 12:06 PM
To: Tomcat Users List
Cc:
Subject: Re: Filter: Reading the http response content
You must wrap the response in a HttpServletResponse wrapper then
override the getOutputStream/Writer with your own methods which provide
a "proxy" to the real getOutputStream/Writer. The wrapped object then
goes to the next filter in the chain.
In other words, a pain in the a$$. Before re-inventing this - look
around to what other people already did.
If you really want to do this - look at the various compression fitlers
available and store in cache instead of compress.
-Tim
rf wrote:
> In my filter I want to cache the content of
> HttpServletResponse so that I can save that in a file
> and use a static file's servlet for the next request.
> However, I am not able find interface to get the
> (html)content from the response object.
>
> if (up2date) {
> RequestDispatcher rd =
> request.getServletDispatcher ("static.html");
> rd.forward (request, response);
> }
> else
> {
> chain.doFilter (request, response);
> //***Then save the html response to static html
> }
>
>
> So any clues as to how to obtain the "content" of
> response. The HttpServletResponse has methods to
> get/set the HTTP headers and cookies, but does not
> have anything for the HTTP's body. It is also not
> possible to read from response.getOutputStream.
>
> What do you guys think?
>
> Thank you
> ~rf
>
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
> http://mailplus.yahoo.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]