aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Problem related to cookies Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Problem related to cookies" Watch "Problem related to cookies" New topic
Author

Problem related to cookies

shveta gupta
Greenhorn

Joined: Jul 12, 2006
Posts: 4
In the servlet specification it is specified that session tracking cookie must be JSESSIONID...
but in HFSJ (CH-6 pg 248)they have specified that one can tell a cookie to stay alive even after the browser shuts down and in the example they have written

Set-Cookie:username=x

and

Cookie:username=x.

Kindly solve this problem as I am getting confused that is there a restriction on the name of the cookie or not???
Thanks in advance.
Vassili Vladimir
Ranch Hand

Joined: Mar 08, 2007
Posts: 1585
Hi,

Yes you can do that by calling the setMaxAge(), but when you call getMaxAge() on the the JSESSIONID cookie, you will get the value -1, which means, it will disappear when the user closes the browser.

I hope that i made myself clear ...


Vassili ...
SCJP 5.0, SCWCD 1.4, SCJA 1.0
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Hi Shveta,


public void Cookie.setMaxAge(int expiry)
Specifies the maximum age of the cookie in seconds before it expires. A
negative value indicates the default, that the cookie should expire when
the browser exits. A zero value tells the browser to delete the cookie
immediately.




With Regards,


cmbhatt
shveta gupta
Greenhorn

Joined: Jul 12, 2006
Posts: 4
Actually i wanted to know that whether there is a cookie naming restriction or not.....???
Chandra Bhatt
Ranch Hand

Joined: Feb 28, 2007
Posts: 1707
Shveta:

Actually i wanted to know that whether there is a cookie naming restriction or not.....???



No, there is no naming restriction to cookies. You can name it like "123". But to access it from the JSP, you have to do like:

In servlet:


In JSP:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Problem related to cookies