• Post Reply Bookmark Topic Watch Topic
  • New Topic

Persistent Cookies in Servlets  RSS feed

 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
I have the following simple App:
---------------The method name is changed in the code accrd. to the JavaRanch naming convention---

TestCookieServlet- In this servlet, I'm creating a new cookie and adding the same to the response, and finally forwarding the request to another component.


DisplayCookies In this file I'm getting all cookies from the request, as shown here:


I have two queries:
(1) For the first time when I request TestCookieServlet (whin inturn forwards the call to DisplayCookies) I get to see- "There are no cookies for this request". But, when I refresh the page I get the cookies name and value. Why it doesn't show me the same result on the first request?

(2) Why is the path always shown null?

Any help shall be highly appreciated.

Thanks,
Reema
[ January 13, 2007: Message edited by: Reema Patel ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I correctly understand your question -
Cookies are set in the response and the browser will not get the cookies until the response is sent. The servlet will not see cookies until the NEXT request.

Bill
 
Reema Patel
Ranch Hand
Posts: 169
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Bill,
Thanks for the post.
I think you have a point.
Now, instead of a forward I'm doing a redirect and thinks are looking pretty.

Thanks,
Reema
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!