• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

cookies in JSP

 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all,
Is it ok to set cookies through JSP, what exactly I am trying to achieve is, when the user visits the home.jsp page for the first time, a welcome note displaying "Welcome USER" is displayed, with other info on the homepage, after that if he posts his information on the site, I would like to store his user id in cookie, so that the other time he visits the same page, I will get his name from his id & display "Welcome <firstname>"...(something of the sort thats done on javaranch)...
tia
MB
 
Malhar Barai
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi all
is the group dead, or am I not clear in asking the question...
MB
 
Malhar Barai
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi..
Now that the authors are also going be over here, could they answer my query, I am really stuck at it & a bit confused too...
tia
MB
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Malhar,
If your question is "Is it okay to set cookies in JSP?," I think the answer is "Yes."
Why you might not has some reasons however. One is that it puts Java code in the page and makes maintenance a bit troublesome down the road in a complex web application. However, if this is a simple application, then it's perfectly fine. MVC design here however is always best.
Also consider that you "add" Cookies, not "set" Cookies.
Tim
 
Malhar Barai
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
When the first page to be loaded is in itself a JSP page, how would I go about using MVC design n retrieving the cookies. Would it be ok to "add" the cookie using a bean..??
bit confused on that...
tia
MB
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic