Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

session timeout

 
shailesh kumar
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my application I have this session timeout javascript function and works well. I have to give timeout message to the user after 20 mins of inactivity. We have some applets also. But the timeout function gives the alert message even if the user is working on the applet. I understand that Browser and applet are two diffrent things, i guess thats why its not working properly. Is there a good way to implement this functionality in applets ?, please advice.

Function:

function ShowTimeoutWarning()
{
window.alert( "Your session has been timed out. As a security precaution, sessions are invalidated after 20 minutes of inactivity. You can log in again to resume.!" );
window.location.href="Login.jsp";
}

setTimeout( 'ShowTimeoutWarning();', 60000 );
 
Ulf Dittmer
Rancher
Posts: 42967
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You could keep track of the time each time the user does something in the GUI; the event handlers would be a good place for this. If at some point the time since the last event is more than 20 minutes you can require a re-login.

But it sounds like you only want to time out if the user accesses neither the web page nor the applet - correct? For that you'd need to implement some kind of Java<-->JavaScript interaction; some hints on how to do that can be found here.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic