tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Konstantin Kolinko <>
Subject Re: Overriding Close method of a Output print writer through HttpServletResponseWrapper
Date Sun, 03 Feb 2013 21:26:06 GMT
2013/2/2 Arnab Ghosh <>:
> I need a help for the following problem -
> 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. 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. 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 -
> I have overridden the getOutPutStream/Getwriter method and those method will return my
custom classes. I have also overridden the flushbuffer method.

1. Tomcat version = ?

2. response.addCookie() method is a proxy for
response.addHeader("Set-Cookie", ...),
--- See its implementation in org.apache.catalina.connector.Response class.

In a Servlet 3.0 application unless response has been committed, its
headers can be read and overwritten with a combination of
getHeaders(), setHeader(), addHeader() calls.

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

View raw message