How to keep the session alive, when web app is inactive?

A

aneta737

Hello,

I have a web (Struts based) application which holds almost all info
about what user is logged in and what he was currently doing in a
session.

Once the session expires, all info is lost and users get errors... so
they have to re-open the application and re-login.

I have a Websphere timeout set to 30 mins (I can't change that). What
can I do to keep the session ALIVE when the user is not using the
application?

I have heard of Socket.keepAlive(true) method. Would that work for me?

Any help would be appreciated.
 
C

Comics

Can't change timeout in Web.xml?
So, use "timer/thread" to put something into session in certain interval.
 
A

aneta737

Actually, my application is using a common company API that controls
the login. I believe there are other INACTIVE settings that kill my
session.

What can I do to "pretent" that someone is working on the application,
i.e. gets or sends requests to/from the server.

I've read that Socket.keepAlive(true) will send the packet only after 2
hours. Is there something like that I could implement but I need to
send packets more often (less than 30 min)?
 
A

Abhijat Vatsyayan

What is wrong with method "setMaxInactiveInterval" ? This should
override any timeout specified in web.xml .

Abhijat
 
B

Bruce Lewis

I have a web (Struts based) application which holds almost all info
about what user is logged in and what he was currently doing in a
session.

That's precisely your problem. The only info that should ever go in a
session variable is info that can be easily reconstructed or info you
don't care about.

Your login system should be able to reauthenticate a user no matter what
they're doing.

Info about what a user is currently doing belongs in URLs or hidden form
variables. The side that cares about the info is the one that should
keep it.

There's a reason why statelessness on the server side is one of the
bragging points of HTTP.
 
I

isamura

: Hello,
:
: I have a web (Struts based) application which holds almost all info
: about what user is logged in and what he was currently doing in a
: session.
:
: Once the session expires, all info is lost and users get errors... so
: they have to re-open the application and re-login.
:
: I have a Websphere timeout set to 30 mins (I can't change that). What
: can I do to keep the session ALIVE when the user is not using the
: application?
:
One approach may be provide a link to a keepSessionAlive.jsp page where the page automatically
refreshes at regular interval. Of course this page will have to "live" in a separate tab or window.

..k
 
R

Robert

I second isamura. We use the XMLHttpRequest to keep the app in
constant contact with the server, about every minute or so as long as
the window stays open. As soon as someone closes the app they drop
their session but if they leave the window open all day and don't log
out their session lives on and they can come back to it whenever. The
only time this is a problem is when the users do a task that takes a
long time for a page refresh and it occassionally times out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,754
Messages
2,569,527
Members
45,000
Latest member
MurrayKeync

Latest Threads

Top