-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Makaira,

On 2/17/2009 5:38 PM, makaira nigricans wrote:
> So after my all my dilemmas
> JSESSIONID is simple cookie!

Yes, containing only the id of the HttpSession living on the server. You
can look at this cookie's contents by watching the HTTP traffic between
client and server using LiveHTTPHeaders (a Firefox add-on) or similar
add-on to another browser, or by using a TCP sniffer such as Wireshark.

> But I still do not know is this the cookie
> which exists only when browser is opened because I closed browser and run my
> cookie-printing servlet which printed this cookie again?!

I suspect that you had another browser window opened somewhere. If you
don't close all the browser windows, then the browser is still
considered to be running, and your cookie will continue to be sent.

> You said that through the HttpSession object I can access the cookies

This was an incorrect statement.

> and
> you said and that JSESSIONID attribute is handled by Tomcat but you said "It
> is enough to add the attribute(s) you will later use." Does this means that
> I can add more values to JSESSIONID cookie?!

Cookies can have only one value. The JSESSIONID cookie has the only
value it will ever need: the id of the session. Don't mess around with
the JSESSIONID cookie.

> If I can this is great, it solves my problem, I can check with my second
> servlet is JSESSIONID present and I can check does it contains my value and
> if it does I redirect, if it doesn't I inform user.

I think you need to be more clear about your requirements. Do you just
want to know if the user has visited your "second servlet" during their
session? If so, then you can simply store that fact as an attribute of
the session. Something like this:

session.setAttribute("did-visit-second-servlet", Boolean.TRUE);

You can check for this value like this:

if(Boolean.TRUE.equals(session.getAttribute("did-visit-second-servlet")))
{
   response.sendRedirect("http://www.google.com/";);
   return;
}

- -chris
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkmcb7oACgkQ9CaO5/Lv0PC+2gCghSo7c9nOL5YJRldbJSf/b3YH
DkoAoJPUu6KiHqcCV8Oy4VQO1d8bfLXG
=yTiS
-----END PGP SIGNATURE-----

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

Reply via email to