File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session Tracking across doPost() & doGet()" Watch "Session Tracking across doPost() & doGet()" New topic
Author

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,
Chinmay....


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
SCJP,SCWCD
Chinmay Bajikar
Ranch Hand

Joined: Dec 08, 2001
Posts: 159
Hi,
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="http://192.146.0.20:8080/servlet/MyServlet" method=Post>
Where "192.146.0.20" 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 192.146.0.20
point to the same machine?
Conclusion:- Problem Solved But Not Understood.
David O'Meara
Rancher

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.
Dave
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session Tracking across doPost() & doGet()