Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

where cookies disappeared?

 
Maulin Vasavada
Ranch Hand
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1873
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic