You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by to...@lemko.com on 2007/08/06 19:12:49 UTC

cookies

Hi

I am adding some additional functionality to something that someone did who has left the company.
He was using Web Macros under tomcat (webapps/application/WEB-INFO: code, templates, etc).

He has something called login.html which uses a login.java compiled program to set a cookie
(response.addCookie( "UserLevel", "value") ) which adds a cookie called UserLevel with a
value retrieved from logging in. His other java code does a request.getCookies() and goes through
the cookies to find "UserLevel" from which he then gets the values.

I am adding on in JSP (rather than web macros). I can't really rewrite what he did. I have the user
go to his login page and login, and then type the url of my jsp (which is under the same application
as the above, but under jsp). My code does the same thing, does getCookies[] and looks for "UserLevel".
Problem is, it does not find it. When I do the Edit->Preferences->"Show Cookies", UserLevel is there
with the correct value, but all my java jsp code can find is the session ID.

Does anyone know what I am doing wrong, or how I can get the recently-added cookie?

I am using firefox.

Directories (under/root/tomcat/webapps/<name_of_application>):

WEB-INF web information
 --Code Java code
 --Classes Compiled Java Code
 --templates web macros
html html files
jsp jsp files

Thanks
Tony



Re: cookies

Posted by Christopher Schultz <ch...@christopherschultz.net>.
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Tony,

tony.chamberlain@lemko.com wrote:
> He has something called login.html which uses a login.java compiled
> program to set a cookie (response.addCookie( "UserLevel", "value") )
> which adds a cookie called UserLevel with a value retrieved from
> logging in. His other java code does a request.getCookies() and goes
> through the cookies to find "UserLevel" from which he then gets the
> values.

That sounds pretty standard. You ought to be able to replicate this
capability pretty easily.

> My code does the same thing, does
> getCookies[] and looks for "UserLevel". Problem is, it does not find
> it. When I do the Edit->Preferences->"Show Cookies", UserLevel is
> there with the correct value, but all my java jsp code can find is
> the session ID.

Can you post your "cookie finding" code? Also, post the portion of your
(new) code that /sets/ the cookie. Often, cookie-related issues are tied
to incorrect setting of the "path" of the cookie. Also, are you using
SSL at all? If so, please describe any changes from/to SSL requests
during this process.

> Does anyone know what I am doing wrong, or how I can get the
> recently-added cookie?
> 
> I am using firefox.

Oh, good. There are several tools available for ff that are useful in
this regard. LiveHTTPHeaders is an add-on that allows you to snoop the
request and response headers of HTTP transactions. Once installed, you
can just open a LiveHTTPHeaders window and then go through your login
process. You can see the headers for all page requests until you clear
the buffer, so you can verify that, at least, the cookies are being sent
correctly.

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

iD8DBQFGt2CH9CaO5/Lv0PARAo7YAJ92cq9fGzFhA4OBH1yJt19PKMHwGQCfecGy
85fW97ugj27ORccs95Rv5pM=
=t321
-----END PGP SIGNATURE-----

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