Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to alert user before session expires in Java?

Tags:

java

session

How to alert user before session expires in Java?

In StackOverflow this question is discussed so many times. But my question is slightly different. I have a requirement to modify the existing application. My application is very big. Session will be expired after 30 mins if there is no response from the user. I want to display the alert before session expires, say at the 25th min I would like to display a prompt to user about session expires

In my application, more than 2000 jsp's are used and no common js is used. So I cannot change all the jsp file to include the javascript code for checking the session timeout.

How to handle this?

like image 937
Elayaa Avatar asked Apr 19 '26 12:04

Elayaa


1 Answers

Create an iframe, and put the jsp pages inside there.

In the top page, that the iframe is within, then have javascript monitor for the jsp page changing (https://stackoverflow.com/a/1930942/67566).

If the jsp page hasn't changed in 25 mins you can warn the user.

If you are using ajax calls within your jsp pages then this will be more problematic, but the fact that you have so many jsp pages leads me to assume you aren't.

like image 55
James Black Avatar answered Apr 21 '26 02:04

James Black