File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSP and the fly likes Unable to set cookies with jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to set cookies with jsp" Watch "Unable to set cookies with jsp" New topic
Author

Unable to set cookies with jsp

Tomas Nilson
Ranch Hand

Joined: Jan 14, 2002
Posts: 33
Hey!
If I for example use the following code in a JSP page:
Cookie cookie = new Cookie("t", "v");
cookie.setMaxAge(60 * 60); //1 h in seconds
response.addCookie(cookie);
Will I be able to access a cookie named "t" next time I visit this site (if it's within an hour)? Or do I have to do something to actually set the cookie? I can't get it to work..
Please help...:-) //Tom
Nathaniel Stoddard
Ranch Hand

Joined: May 29, 2003
Posts: 1258
Do you need to specify the domain and/or the path for the cookie? I'm not sure if the response will take care of that when you call addCookie(). Otherwise, I don't see anything wrong with this. (Sorry, I'm not much help here -- I haven't had too much experience with cookies in JSP.)


Nathaniel Stodard<br />SCJP, SCJD, SCWCD, SCBCD, SCDJWS, ICAD, ICSD, ICED
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Unable to set cookies with jsp
 
Similar Threads
Cookies not getting reset in Netscape 4.72!!! URGENT!!!
setMaxAge on cookie using JSTL
Confusion about session destruction
Setting Cookie
Not able to set cookies