• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

servlet Session

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i use Httpsession object created in get method of servlet into post method of same servlet.
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I don't think so, you must create a new reference to HttpSession in the doPost method unless you either create an instance variable(which is not recommended) or another example is to pass both the HttpServletRequest and HttpServletResponse as well as the HttpSession to a single method called by both the doGet and the doPost methods. The HttpSession object is not implicit like it would be in a JSP page.
I hope this helps.
Craig
 
Ranch Hand
Posts: 365
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
From doGet(request, response)
call doPost(request, response)
in doPost call request.getSession()
but then all of your pages would have to call doGet so this may not be what you're looking for.
 
Craig Jackson
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are correct William.
Let me correct what I stated above, I wasn't thinking clearly.
Another alternative would be to:
 
    Bookmark Topic Watch Topic
  • New Topic