tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject Re: Newbie cookie question
Date Fri, 17 Jan 2003 17:27:43 GMT

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

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

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



Hello joel,

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


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

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

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

View raw message