jQuery in Action, 2nd edition*
The moose likes Servlets and the fly likes Setting Cookie Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Setting Cookie" Watch "Setting Cookie" New topic
Author

Setting Cookie

Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
I have created a small application to create and set cookie. My servlet code is bellow.



can anybody tell me what will this code do ?
and if it is creating cookie than where can i see my cookie ?
what will be the default location of my cookie ?
how cn i set the cookie location ?
I want to set the cookie at client end.


Jigar Naik


Shu Gao
Greenhorn

Joined: Aug 01, 2005
Posts: 18
This code creates a cookie named 'param1', and map its value to whatever the value of the query parameter 'param1' is, and its expiry value is 1800 seconds.

developers don't need to worry about the location, the cookie is by default stored on client-end, where the location is where your browser store your temporary internet files.

Hope that helps.


SCJP 1.4<br />SCJD<br />SCWCD 1.4
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
but how do i retrive the name value pairs stored in the cookie ?
Jigar Naik
Ranch Hand

Joined: Dec 12, 2006
Posts: 755
and what does this function doing



I had written it to know the location of cookie at client end.
Muhammad Saifuddin
Ranch Hand

Joined: Dec 06, 2005
Posts: 1321

Originally posted by Jigar Naik:
and what does this function doing



Java Doc would be your first place to know about it..Cookie.getPath
[ January 08, 2007: Message edited by: Saif uddin ]

Saifuddin..
[Blog][Linkedin] How To Ask Questions On JavaRanch My OpenSource
santhoshkumar samala
Ranch Hand

Joined: Nov 12, 2003
Posts: 156

you can get name value pairs by using following code



loop through cookies array using a for or while loop



santhosh<br />SCJP,SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting Cookie