aspose file tools*
The moose likes JSP and the fly likes doing a submit when window is closed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "doing a submit when window is closed" Watch "doing a submit when window is closed" New topic
Author

doing a submit when window is closed

Ezra Exposito
Ranch Hand

Joined: Apr 26, 2001
Posts: 34
I am writing an app for multiple users and I need to lock/unlock records while users are updating information. My problem is with unlocking because a user can just close the browser and forget to unlock the record. I tried using the unload event
as shown below but it doesn't work.

The alert box will display but then nothing happens and it never goes back to the servlet.
Any help would be greatly appreciated.
Thanks,
Ezra
Kyle Brown
author
Ranch Hand

Joined: Aug 10, 2001
Posts: 3892
    
    5
This is the most commonly asked question in this entire forum. Do a search and you'll find it answered many times.
The answer is you can't. There's no way to communiate to the server when they close the browser. The closest you can come is to use the HttpSessionBindingListener interface so that when the user's session times out it closes your files, or unlocks your records, or whatever.
By the way, I would consider any implementation that locks records between HTTP calls to be HIGHLY suspect. You really shouldn't do that! Try using optimistic concurrency (timestamps) instead of pessimistic concurrency. Your life will be much easier in the long run.
Kyle


Kyle Brown, Author of Persistence in the Enterprise and Enterprise Java Programming with IBM Websphere, 2nd Edition
See my homepage at http://www.kyle-brown.com/ for other WebSphere information.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: doing a submit when window is closed