ssheikh7
asked on
Reset login indicator after session timeout.
Hello,
I have a Java/STRUTS application running on Websphere Application Server 6.0 with a DB2 database. I need to set the session timeout on the WAS to 480mins (users request).
I'd like to know how i can reset a field in the DB2 table from 1 to 0 when a session timeout occurs. The reason for this is when the user attempts to logon after the session timeout the field is still set to 1 and will inform the user that they are already logged in!! Of course when the user logs off correctly the field is reset to 0.
Thanks in advance.
I have a Java/STRUTS application running on Websphere Application Server 6.0 with a DB2 database. I need to set the session timeout on the WAS to 480mins (users request).
I'd like to know how i can reset a field in the DB2 table from 1 to 0 when a session timeout occurs. The reason for this is when the user attempts to logon after the session timeout the field is still set to 1 and will inform the user that they are already logged in!! Of course when the user logs off correctly the field is reset to 0.
Thanks in advance.
you can also write a listner which implements HttpSessionListener. this listner will be called whenever a session is created and destroyed.
you can write your code for setting the DB2 value in the sessionDestroyed method of the session listener. this sessionDestroyed method will be called whenever the session is invalidated or times out.
you can write your code for setting the DB2 value in the sessionDestroyed method of the session listener. this sessionDestroyed method will be called whenever the session is invalidated or times out.
ASKER
Hi mbvvsatish
Do you have a example for this listener and how implement it?
Also would this be called regardless of where the session timeout occurs. I.e. session timeout could be set on the WAS or within the web.xml. The current plan is to set it within the WAS.
Thanks in advance.
Do you have a example for this listener and how implement it?
Also would this be called regardless of where the session timeout occurs. I.e. session timeout could be set on the WAS or within the web.xml. The current plan is to set it within the WAS.
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you mbvvsatish. I had it working on Friday.
<html>
<head>
<script language=javascript>
var secondsLeft; // seconds left before timeout
var sampleFrequency = 1; // frequency to peek at time left
var interval = null; // timer
var minutesleftWarning = 2; // when to warn user (in minutes)
var hasBeenWarned = false;
function InitTimeoutCountdown()
{
secondsLeft = 125;
hasBeenWarned = false;
if(interval)
clearInterval(interval);
interval = setInterval("CheckForSessi
}
function CheckForSessionTimeout()
{
secondsLeft = secondsLeft - sampleFrequency;
document.mainform.tbox.val
if (secondsLeft < minutesleftWarning * 60)
{
if (!hasBeenWarned)
{
hasBeenWarned = true;
var warning = "Warning: You are about to be logged out in the next {0} minutes";
var mSecsBefore = new Date().getTime();
warning = warning.replace("{0}",minu
alert(warning);
var mSecsAfter = new Date().getTime();
secondsLeft = secondsLeft - (mSecsAfter - mSecsBefore)/1000;
if(secondsLeft>1)
secondsLeft = 125;
}
}
if (secondsLeft < 1)
document.location.href="Lo
}
</script>
</head>
<body onload="InitTimeoutCountdo
<form name="mainform">
<input type=text name=tbox> Seconds Left
</form>
</body>
</html>