• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doing a submit when window is closed

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
author
Posts: 3892
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
My name is Inigo Montoya, you killed my father, prepare to read a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic