Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2004-08-25
9
Medium Priority
?
329 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 252 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 248 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
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!

 
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

As much as Microsoft wants to kill off PST file support, just as they tried to do with public folders, there are still times when it is useful or downright necessary to export Exchange mailboxes to PST files. Thankfully, it is still possible to e…
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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