Well John,

    I'm not a specialist about Cookies, but something is quite surprising in your code 
:

 -> you call getCookies() method on the request object to retrieve all the cookies 
sent by the browser. But, if you want to change the value, you have to overwrite it on 
the client, so according to me you necessarily have to call response.addCookie() 
method if you want your change to be stored....

    Well, just correct me if I'm wrong, but your code should look like

Cookie[] cookie = request.getCookies();
for(int counter = 0;counter < cookie.length;counter++) {
   if(cookie[counter].getName().equals("foo")) {
      cookie[counter].setValue("1234");
      response.addCookie(cookie[counter]);
   }
}

 regards,

    Franck

----- Message d'origine -----
De : "John Doe" <[EMAIL PROTECTED]>
� : <[EMAIL PROTECTED]>
Envoy� : mardi 23 mai 2000 05:55
Objet : setting cookie values


> Hello,
> I am trying to set a cookie value in my JSP page and I just can't seem to get
> it to write to the cookie file.  Here is what Im doing:
>
> Cookie[] cookie = request.getCookies();
> for(int counter = 0;counter < cookie.length;counter++) {
>   if(cookie[counter].getName().equals("foo")) {
>      cookie[counter].setValue("1234");
>   }
> }
>
> When I  retrieve the value immediately after setting it, using getValue() it
> returns me the correct value which i set (1234), however when i look in the
> cookie file it has not been set.  And of course when i move onto other pages
> and check the value it has not been set, it still displays its old value.
>
> One note on this is that the cookie value already exists and so im trying to
> overwrite it with this new value....though i doubt this should be the problem.
>
> Any help would be appreciated. Thanks in advance.
>
> Rostom
>
>
> __________________________________________________
> Do You Yahoo!?
> Send instant messages & get email alerts with Yahoo! Messenger.
> http://im.yahoo.com/
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> Some relevant FAQs on JSP/Servlets can be found at:
>
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
>  http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to