File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes valueUnbound problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "valueUnbound problem" Watch "valueUnbound problem" New topic

valueUnbound problem

Mike Stan

Joined: Feb 03, 2004
Posts: 1
I'm trying to figure out how to close a user session when he or she closes the web browser.
The ValueUnbound event is invoked only when session timeout expires.
any ideas??
Jason Menard

Joined: Nov 09, 2000
Posts: 6450
Oddly enough I just had to deal with this problem myself today. Check out this thread in the HTML/JavaScript forum.
From my code in that thread you can see how to fire off a JavaScript function when the browser is closed or a user navigates off of your site. That JavaScript function opens a new window and points to a servlet/JSP/Struts Action/whatever that does any cleanup you need done and invalidates the session. I use Struts, so I have my struts Action forward to a page that simply closes itself, thus getting rid of the popup you just opened. You can do this by placing on1oad="self.close()" (replace the number 1 with L there, UBB can be a pain sometimes) in your <body> tag.
I agree. Here's the link:
subject: valueUnbound problem
It's not a secret anymore!