aspose file tools
The moose likes Servlets and the fly likes Persistent Cookies in Servlets Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Persistent Cookies in Servlets" Watch "Persistent Cookies in Servlets" New topic
Author

Persistent Cookies in Servlets

Reema Patel
Ranch Hand

Joined: Jan 26, 2006
Posts: 169
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

Joined: Mar 22, 2000
Posts: 12266
    
    1
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


Java Resources at www.wbrogden.com
Reema Patel
Ranch Hand

Joined: Jan 26, 2006
Posts: 169
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Persistent Cookies in Servlets
 
Similar Threads
Create Cookie and display the Cookie values.
strange reading cookie problem
Persistent Cookies with Servlets
http header and cookie case sensitive
kookie.getMAxAge