*
The moose likes Servlets and the fly likes servlet Session Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "servlet Session" Watch "servlet Session" New topic
Author

servlet Session

Henry Hill
Greenhorn

Joined: Mar 05, 2004
Posts: 1
can i use Httpsession object created in get method of servlet into post method of same servlet.
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
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
Scott Duncan
Ranch Hand

Joined: Nov 01, 2002
Posts: 363
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.


No more rhymes! I mean it!<br /> <br />Does anybody want a peanut?
Craig Jackson
Ranch Hand

Joined: Mar 19, 2002
Posts: 405
You are correct William.
Let me correct what I stated above, I wasn't thinking clearly.
Another alternative would be to:
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: servlet Session
 
Similar Threads
destroy() method of servlet.
POST or GET
init missing in servlet
Trying to access a servlet on button click
Servlet method call