Solved

When sessions is timeout , a new javascript window appears on screen?

Posted on 2004-08-25
9
318 Views
Last Modified: 2012-06-27
Hi dear experts,
I am using tomcat 5.0.x and developing web application with jsp. When my client session is time out , I want to show popup window saying that "your session is dead because you didnt do anything for 15 minutes".
How can i do this ?  to know when session it time out i have to write a listener  but how can i popup a windows through servlet or jsp when session is time out?
0
Comment
Question by:elmakarge
  • 3
  • 3
9 Comments
 
LVL 35

Accepted Solution

by:
TimYates earned 63 total points
ID: 11900176
This will have to be on a page refresh, you cannot just pop windows up without the client requesting a page

Also, remember that new browsers block popups (IE 6, SP2 -- Firefox -- Opera), so most people won't see your popup anyway...

When the session times out, it is destroyed, so you will have to check for a value in the current session.  If the value is not there, tell them they have to log in (and that it may be because they timed out), then send them to the login page (you can store the current page in the session, so they can automatically return to their current page after a successful login)

Tim
0
 
LVL 19

Assisted Solution

by:ramazanyich
ramazanyich earned 62 total points
ID: 11900204
You can't initiate any client action from server. So you need add  javascript function (eg. name it auth) into all your pages which will do some action after some time.
and call it using <body onLoad="setTimeout(function,15*60*1000)">
15 can be replaced by your sessioin timeout.

in function auth you can perform some checks and open new window.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11900216
Ooooh!  Nice :-)

Of course, if you change your timeout in web.xml, you will need to change all of your jsp's too ;-)
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 19

Expert Comment

by:ramazanyich
ID: 11900248
You can use session.getMaxInactiveInterval() API call to set timeout value dynamically in your HTML output
0
 

Author Comment

by:elmakarge
ID: 11900287
Why do i have to change all jsp files   Cant i pass  session timeout value from  web.xml to javascript by a variable ?  I know that we  reach paramter values in web.xml  from jsp files?
Am i wrong ?
0
 
LVL 35

Expert Comment

by:TimYates
ID: 11900310
> Cant i pass  session timeout value from  web.xml to javascript by a variable ?

ramazanyich just showed you how :-)

<body onLoad="setTimeout( function, <%= session.getMaxInactiveInterval() %> * 60 * 1000 )">
0
 
LVL 19

Expert Comment

by:ramazanyich
ID: 11900342
NOTE: getMaxInactiveInterval() returns timeout in seconds. So you should remove *60. Modified string will look like:
<body onLoad="setTimeout( function, <%= session.getMaxInactiveInterval() %>  * 1000 )">
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Find out what the Office 365 disclaimer function is, why you would use it and its limited ability to create Office 365 signatures.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now