Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Can't add cookies on Localhost

807598Feb 3 2006 — edited Feb 3 2006
Hi,
I am trying to save cookie and then read it in the same JSP page. But I can't read it, not sure if its been added. Here is the script below:


Cookie c = new Cookie("Test", "123455");
c.setMaxAge(-1);
response.addCookie(c);

Cookie[] allCookie = request.getCookies();



if (allCookie != null)
{
for (int i =0; i< allCookie.length; i++)
{
Cookie c = allCookie;
System.out.print (i+" Name:" + allCookie[i].getName());
System.out.print (" Value:" + allCookie[i].getValue());
System.out.print(" Domain: "+allCookie[i].getDomain());
System.out.println(" Path: "+allCookie[i].getPath());
System.out.println(" MaxAge: "+allCookie[i].getMaxAge());

Where is this cookie is saved? Can I see manually if its been added? Also, the cookie showing(not "Test"), has domain and path as "null". Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 3 2006
Added on Feb 3 2006
5 comments
425 views