This week's book giveaway is in the OCAJP 8 forum.
We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line!
See this thread for details.
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

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Unable to set cookies with jsp" Watch "Unable to set cookies with jsp" New topic

Unable to set cookies with jsp

Tomas Nilson
Ranch Hand

Joined: Jan 14, 2002
Posts: 33
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
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.)

I agree. Here's the link:
subject: Unable to set cookies with jsp
It's not a secret anymore!