Meaningless Drivel is fun!*
The moose likes Servlets and the fly likes Cookie Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Cookie Problem" Watch "Cookie Problem" New topic

Cookie Problem

Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
I'm using the following code to check for the exisitance of a cookie, if it doesn't exist a new one is created with the value of a countrychoicecode passed in.
If a cookie already exists I want to modify the countrychoicecode and rewrite the cookie.
The problem is that when I try to modify the cookie and rewrite it the cookie dissappears.
Anyone experienced this before or see where i'm going wrong?
FYI the RequestHelper class used here is used to get hold of a specific cookie from the HttpRequest, this is working fine.

[This message has been edited by Angela Poynton (edited August 21, 2001).]

Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
Can anyone help me here? This is getting really frustrating!
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15950

Just as a quick check - are you writing out anything BEFORE you get to this code? Cookies are header constructs.

Customer surveys are for companies who didn't pay proper attention to begin with.
Angela Poynton
Ranch Hand

Joined: Mar 02, 2000
Posts: 3143
Hmmm you may have it there .... this code is in a Servlet which is called by the FORM ACTION directive in a JSP ... this JSP is included by a template JSP.
Tricky ...
I agree. Here's the link:
subject: Cookie Problem
Similar Threads
Loop through cookies and get value for a particular cookie name.
Cookies not getting reset in Netscape 4.72!!! URGENT!!!
How do i delete a cookie whose path I do not know ?
Using Cookies to Prevent Multiple Sends