File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Session Tracking across doPost() & doGet() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Tracking across doPost() & doGet()" Watch "Session Tracking across doPost() & doGet()" New topic

Session Tracking across doPost() & doGet()

Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
I have a Login page from where I Login.
The submit for this login is being handled by the doPost() of servlet.Here i set the session with the Loginid and passwd in it.
Then I have another page which asks for information from the server.The submit for this form will call doGet() and this in turn tries to get the session which has been currently set thru doPost().But what I m getting is a diff session with the heetsession.getValueNames() returning 0 length String[].
Can anyone tell me why this is happening?
thanks in adv,

The strength of the Wolf is the pack & the strength of the pack is the wolf....Rudyard Kipling
Asher Tarnopolski
Ranch Hand

Joined: Jul 28, 2001
Posts: 260
post your code.

Asher Tarnopolski
Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
I did get over the problem.But I dont understand how.
Here is what I did?
My login page called the Servlet in this way,
<form action="" method=Post>
Where "" is the ip of my machine.
But the page which did a get , call my servlet in this way,
<form action="http://localhost:8080/servlet/MyServlet" method=Get>
What differance does this make for Session Management,since both localhost and
point to the same machine?
Conclusion:- Problem Solved But Not Understood.
David O'Meara

Joined: Mar 06, 2001
Posts: 13459

They are the same machine, but the browser can't tell that. It will only send the session id if it can verify that they are the same server. even if you send the domain name in some links and the IP in others you will still lose the session.
I agree. Here's the link:
subject: Session Tracking across doPost() & doGet()
It's not a secret anymore!