tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <>
Subject Re: Overriding Close method of a Output print writer through HttpServletResponseWrapper
Date Sun, 03 Feb 2013 20:01:03 GMT
Hash: SHA256


On 2/2/13 4:31 AM, Arnab Ghosh wrote:
> I have a web application where cookies are getting added multiple 
> times and because of that response header is becoming big
> containing many duplicate cookies. Now the web application is so
> big that it is nearly impossible to correct those cookie logic in a
> short term.
> So I have planned to use a HttpServletResponseWrapper in a Filter.
> It will contain a HashMap. I have overridden the addcookie method
> of the response wrapper. Now the cookies will be added to the map
> instead of response. So it will not have any duplicate cookie.

Okay. Presumably, you'll be adding the cookie(s) once at some point.
Obviously, just sticking them into a HashMap won't actually do
anything where the response is concerned. What are you using for the
key in the HashMap?

> Now I have created a Custom Servlet Output Stream and Print writer
> and overridden the close method. Before closing the stream/writer I
> will take the cookies from map and will add to the actual response
> header.

That's an interesting way to do things. I suppose you want only the
latest cookie to be actually added to the response, though, huh?

> Problem is it works fine with pure servlet. But the close method
> of the stream/writer not getting called when using with JSP. What
> can be the issue -

Can you post your code?

> I have overridden the getOutPutStream/Getwriter method and those 
> method will return my custom classes. I have also overridden the 
> flushbuffer method.

Seeing the code would be very helpful.

- -chris
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools -
Comment: Using GnuPG with Thunderbird -


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

View raw message