File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Notify servlet prior to session invalidate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Notify servlet prior to session invalidate" Watch "Notify servlet prior to session invalidate" New topic
Author

Notify servlet prior to session invalidate

Jeff Satori
Greenhorn

Joined: Jun 06, 2001
Posts: 5
Background Info:
I am working on a project to lock a product id number so it may not be accessed by more than one session at a time. I create a lock by writing the session id, product id number, user id and timestamp to a oracle database table.
What I am trying to do is release the lock when the user ends their session by closing a browser.
Question:
When a session is going to be invalidated because time out interval has been reached, is there a way to call a servlet to perform a "release lock" function?
By the way, I am using Websphere 3.0.2 and Java 1.1.7
Jeff Satori
Greenhorn

Joined: Jun 06, 2001
Posts: 5
OK, I figured out that I should use the HttpSessionBindListener.valueUnbound method but I am still unsure about the syntax which adds the listener to the the session. Could someone help me out with this?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Jeff Satori:
OK, I figured out that I should use the HttpSessionBindListener.valueUnbound method but I am still unsure about the syntax which adds the listener to the the session. Could someone help me out with this?

req.getSession().setAttribute("bean", bean). Provided your bean implements HttpSessionBindingListener, it will be called automagically when it is unbound or the session expires.
You might want to look into the DBMS_LOCK package, by the way.
- Peter
Jeff Satori
Greenhorn

Joined: Jun 06, 2001
Posts: 5
Thanks for your help Peter, that did the trick.
 
 
subject: Notify servlet prior to session invalidate