This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Servlets and the fly likes Session lost on page refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Session lost on page refresh" Watch "Session lost on page refresh" New topic
Author

Session lost on page refresh

koen ja
Greenhorn

Joined: Oct 15, 2007
Posts: 10
Hello,

I have a webapplication deployed on WAS5.1;
it has a page that has to auto-refresh every 30 seconds.

To do so, i put two attributes on the incoming request for the page:

request.setAttribute("refresh_url", "my_url");
request.setAttribute("refresh_time", "30");


So far, so good. The page loads and refreshes every 30 seconds.

Is it required to "enable cookies" in the webcontainer? Then
everything works.
But then I have the problem that the user needs to shut down his
entire browser
to be sure that all session data is cleaned after logout.
If he does not, some data is still present in the session after a new
login
(from the browser cookie I guess?)



When I try the same without "enable cookies", my initial session gets
lost on page refresh.
(and a new one is created on every refresh).

Is there a way to maintain my initial session then?

I already tried:
- adding ";jsessionid=<THE_SESSION_ID_OF_THE_INITIAL_REQUEST>" to the
refresh_url
- getting the jsessionid cookie from the initial request and posting
this to the response




Many thanks!
Koen
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1506
Are you using instance variables somewhere and that is carrying over?


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
koen ja
Greenhorn

Joined: Oct 15, 2007
Posts: 10
An object is saved in session.

Then, when I logout (session.invalidate())
and log in again (even with another user!),
the object is in session scope again.

I don't know alot about cookies..
How does this object get into session scope again?


Koen
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

I'm going to move this to our Websphere (WAS) forum.
I'm not very familiar with WAS but I've heard in passing that it has a proprietary mechanism for keeping sessions alive with cookies that is beyond what is in the servlet spec.

I could be wrong about this and the folks in the WAS forum will know better.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Session lost on page refresh
 
Similar Threads
Session lost on page refresh
jsessionid in URL
Session Management
tomcat session handling
jsessionid always appended to urls on first request