This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes where cookies disappeared? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "where cookies disappeared?" Watch "where cookies disappeared?" New topic
Author

where cookies disappeared?

Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi,
i have a servlet called "test". i have another servlet called "readCookie" and a perl script called "readCookie".
i am inserting cookies in the response from servlet "test" and i have an option of REDIRECTING the request to either the "readCookie" servlet or "readCookie" perl script.
now funny thing happens about which i'm not sure for the reason beneath.
when i redirect from servlet to the servlet it reads back all cookies correctly.
when i try to redirect to the perl script and read the cookies using ENV variable "HTTP_COOKIE" it doesn't find any cookie!!
can anybody explain the reason for this? i think in the second case (perl script) it doesnt' find ENV Var HTTP_COOKIE and that is messing it up but i don't understand when HTTP_COOKIE is set or how i can make it set using servlets.
i thought of using setHeader() or addHeader() method of response object specifying the header name as HTTP_COOKIE but that seem not working for me.
please help me!
regards
maulin
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12761
    
    5
Possibly the CGI that runs the Perl script is not in the same "web application" - how did you set the cookies up? Did you use setPath() to control the URL to which the cookies would be visible?
The rules for cookies visibility, lifetime, etc are in RFC 2109
Bill
Maulin Vasavada
Ranch Hand

Joined: Nov 04, 2001
Posts: 1871
hi william!
i got it! now i understood what is the requirement of setPath()/getPath() in cookies
i was redirecting request to the Perl page under /cgi/something.pl and my servlet context was /servlet so ....the cookie wasn't visible.
i also tried one more thing. i tried to add two cookies having the same name and it did override the first cookie i had so i could only see the second cookie i set with that name. (implementing HashTable/HashMap i guess)...
anyways,
thanks for your guidance. at last i am able to understand setPath()...
regards
mauln
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: where cookies disappeared?
 
Similar Threads
how to invoke perl script on unix server from local machine
session timeout
Communication between Java and Perl
Cookies
VBScript IE Error "The download of the specified resource has failed"