Solved

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

Posted on 2004-08-25
9
326 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's how to start interacting with our community through Post.
Microsoft is moving in-place eDiscovery & hold from ECP to EOP console under Content Search in Search and Investigation Options.  In this post, I will be showing you how to export emails to a PST file using the Content Search Options.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

728 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