I wanted to create a new session, once current servlet session got expired.

81 views Asked by At

i have to avoid the following condition. I'm running the servlet . This session will be expired in Browser after my Time-Out (WEB.XML) period. After getting this time-out, i need to reload this link in Browser to activate this servlet. I don't want to reload the link again, it should be create a new session after the Time-Out.

2

There are 2 answers

0
Will Keeling On

The timeout is the period of inactivity before the session is killed off by the server. If you want to keep the session alive - even when there is no activity - then you could extend the inactivity timeout.

Alternatively you could write a Javascript AJAX keepalive that sends a heartbeat to the server every few minutes. You could write a simple dedicated servlet to receive this keepalive and send back a simple response. The heartbeat would count as activity - and thus keep the session alive.

This post gives an example of the Javascript (the question is C# related but that shouldn't matter).

2
MariuszS On

The correct solution would be extending the time-out (session-timeout) in web.xml.

Your client, JS application in browser should connect to server to announce that it is still live.