Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unable to set cookies with jsp

 
Tomas Nilson
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1258
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.)
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic