File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes Closing popup windows that have timed out Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Closing popup windows that have timed out" Watch "Closing popup windows that have timed out" New topic

Closing popup windows that have timed out

Raghu Marpalli

Joined: Jul 30, 2006
Posts: 6
I am generating a popup window from my application. The application control is such that if the session has timed out, the user is directed to a login page.

If the session has timed out and a popup window is open, clicking on a link takes the user to the login page. I dont want the same to occur as I dont want the user logging in from a popup window etc.

I would rather close out these windows. How can this be accomplished?

Thanks much in advance
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
I can think of a couple of ways you might accomplish this:

1.Automatically refresh the page every minute or so, and have it check for the existence of a session each time it refreshes. If none exists, close the window.

2.The same as number 1, except that you make an AJAX call to the server checking for a session instead of refreshing the page.

3.I've been hearing about something called COMET, which is like AJAX, except that it will allow Javascript code to respond to an event initiated by the server. I don't know much about it, but I was thinking you could implement an Application event listener on the server that fires when the HttpSession is about to time out, and then have the server throw a COMET event that javascript code in the document receives and then closes the window.

Consultant, Sima Solutions
I agree. Here's the link:
subject: Closing popup windows that have timed out
It's not a secret anymore!