File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

regrding window closing

 
Vedhas Pitkar
Ranch Hand
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,all.
Currently i am facing a problem.I have a form which can be opened by only 1 user at any given moment of time.When someone else tries to open the form (opened by someone else),he shoould get an error msg informing that the form is opened by "personName".Ihave set a flag in the database
if opened==Y show error msg
if opened==n allow to open the form.
For this i am storing the username in session var .
The prob i'm facing is that when the user(after opening form) closes the browser window,the database flag stays active ie ='Y'.
Can i have a window closing event so that if he closes the browser,his session will be invalidated?
Or can u suggest some other way?
Any help is appreciated.
Thanx,
Vedhas.
 
Dave Vick
Ranch Hand
Posts: 3244
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Vedhas
You can't detect the window closing on the server side, it can only be done client side with javascript. You need to figure out a way for the javascript to communicate with the servlet on the server, an applet might do it for you.
You can also have the flag expire when the current session ends too, you can detect that server side. In fact you almost have to in case for some reason the client side never lets the server know the window was closed.
hope that helps
 
Erick Jones
Ranch Hand
Posts: 38
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even with javascript there is not a good way to be notified when the user closes the window, unless you provide a logout button. But that will not handle the case when the user just uses the 'x' in the upper right hand corner.
Regards,
Erick
 
Shubhrajit Chatterjee
Ranch Hand
Posts: 356
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is no foolproof method with Javascript as NS4.7 does not suppport trapping of unload event and in any case the client can always disable Javascript. Do it at the server-side by trapping the session time out.
Crude method ...
Keep the session time-out value low, use a frame and refresh one part of the frame continuously. This will keep the session alive when the page is open. When the page is closed in the browser, it will time out quickly.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic