• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Session lost on page refresh

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Ranch Hand
Posts: 1514
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you using instance variables somewhere and that is carrying over?
 
koen ja
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't have to use cookies. However, you should try using Response.encodeURL() with your URL to have it append the session id appropriately. So instead of using

request.setAttribute("refreshURI", "my_URL")

try using:

request.setAttribute("refreshURI", response.encodeURL("my_URL"));

Kyle
 
koen ja
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I tried that with no result:

// note that the encodeUrl method is deprecated..
request.setAttribute("refresh_url", response.encodeUrl("url.do"));
request.setAttribute("refresh_time", "30");


What's weird; before the refresh, the url looks like:
http:/host/path;jsessionid=0000Bc4M4zit89qd_cPowpRQa0v:12thhri2o

after the refresh, the url looks like:
http:/host/path


Any other idea's?
The applicaiton is a struts 1.2 web app. The url in case is a .do url
calling a struts action.




Thanks.
 
koen ja
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For those who care, I found a solution which does keep your session alive:
It's as simple as:

response.setHeader("Refresh", "30;");


You just don't specify the refresh URL.

Regards,
Koen
 
See where your hand is? Not there. It's next to this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic