tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Christopher Schultz <ch...@christopherschultz.net>
Subject Re: Overriding Close method of a Output print writer through HttpServletResponseWrapper
Date Sun, 03 Feb 2013 20:01:03 GMT
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

Arnab,

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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG/MacGPG2 v2.0.17 (Darwin)
Comment: GPGTools - http://gpgtools.org
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iEYEAREIAAYFAlEOwf8ACgkQ9CaO5/Lv0PDc5gCeL4JDpZfq8dxMS/wFleQAky8R
YGcAn0lGzzVg0MfvuAcMii40R8eotCdE
=GsD3
-----END PGP SIGNATURE-----

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org


Mime
View raw message