tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jacob Kjome <>
Subject Re[2]: Newbie cookie question
Date Fri, 17 Jan 2003 18:05:58 GMT
Hello joel,


I assume the problem with the cookie not disappearing upon browser
shutdown is solved, but the issue with seeing this cookie across all
webapps on the same server is not solved, right?

Now that I think about it, I wonder if the path of "/" in servlets is
relative to the context path.  Hence, the path of "/" would actually
mean "/mycontext/".

I'm not sure.  You'll have to play around with things.

Anyone else know the answer to this for sure?


Friday, January 17, 2003, 11:27:43 AM, you wrote:

jdjc> The problem is that it works perfectly on WebSphere 4.x,
jdjc> but not Tomcat ** for the other webapps**.
jdjc> The worst case would be a bug in WebSphere, the
jdjc> production server, that gets fixed someday.

jdjc> This looks right, but am I missing something?---

jdjc>       Cookie aCookie = new Cookie( MY_COOKIE_KEY, cookieText.toString()  );
jdjc>       aCookie.setPath( "/" );                              // deliver to
jdjc> all directories not just issuer.
jdjc>       aCookie.setSecure( false );
jdjc>       aCookie.setMaxAge( -1 );                             // "per-session"
jdjc> cookie, not stored on disk
jdjc>       theResponse.addCookie( aCookie );

jdjc> Thanks,
jdjc> Joel

jdjc> ********

jdjc> Hello joel,

jdjc> Look into how the cookie path is set.  I think, by default, it is set
jdjc> to the current context of your app, not the whole server.  You will
jdjc> need to override this behavior.  See the servlet api for details.  As
jdjc> far as the cookie disappearing upon browser close, this should happen
jdjc> unless you specifically set an expiration date for the cookie of
jdjc> sometime in the future.  Note that *all* open browsers need to be
jdjc> shutdown in order for the cookie to go away.  If you have 2 browser
jdjc> windows open and only shut one down, the cookie will still exist.

jdjc> Jake

jdjc> Friday, January 17, 2003, 8:52:22 AM, you wrote:

jdjc>> All,

jdjc>> Is there any way to code a cookie so that all the webapps
jdjc>> on the same Tomcat server can receive it?

jdjc>> I also need it to disappear when the browser is shut.

jdjc>> Thanks,
jdjc>> Joel

jdjc> This communication is for informational purposes only.  It is not intended as
jdjc> an offer or solicitation for the purchase or sale of any financial instrument
jdjc> or as an official confirmation of any transaction. All market prices, data
jdjc> and other information are not warranted as to completeness or accuracy and
jdjc> are subject to change without notice. Any comments or statements made herein
jdjc> do not necessarily reflect those of J.P. Morgan Chase & Co., its
jdjc> subsidiaries and affiliates.

jdjc> --
jdjc> To unsubscribe, e-mail:   <>
jdjc> For additional commands, e-mail: <>

Best regards,

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

View raw message