• 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 ...
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
  • Mikalai Zaikin

Question on HttpSession and Action class

Ranch Hand
Posts: 10198
Mac PPC Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I have a process wherein I submit to an Action class from my jsp page, I write to the database and return the newly created database entry, create a new HttpSession and put the newly created entry in the Session as an attribute and forward to another jsp page. I do some changes in the second jsp page and write some more information to the database. Now the question here is that, I will create a new HttpSession in the first submit and put that as an attribute in that Session. Now when I call another action class from my second jsp page, I will get the Session attribute from the request and check if that attribute is not null and if it it not, then I will use the values read from that attribute. Well, the question that I have is how would I get the same Session object that I have created in my first jsp submit??
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

If you get the current request's session you'll get *the* session: HttpServletRequest.getSession(boolean). Also note that unless you've explicitly disabled it, visiting any JSP page, directly or via an action, a session will have already been created.

You almost never have to create your own HttpSession locally.
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic