This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Servlets and the fly likes executing code when a session expires? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "executing code when a session expires?" Watch "executing code when a session expires?" New topic
Author

executing code when a session expires?

Can Gencer
Greenhorn

Joined: Nov 01, 2004
Posts: 1
Hello,

I am trying to implement a servlet which draws some temporary images, and then stores them locally with a name that is tied to the session id. Whenever a session ID expires I would like to remove those images, however, I don't know what the best way to do this would be. I know of HttpSessionBindingListener, but apparently my object will only get notified AFTER the session is unbound, so I'm not sure if I'll be able to access the session ID.

I am also using struts, but I doubt they have any code related to that.
Any help would be much appreciated..
Thanks!
[ November 01, 2004: Message edited by: Can Gencer ]
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12769
    
    5
As you say, when a HttpSessionBindingListener is notified with valueUnbound, the session is probably invalid. The solution is to hold the references of interest inside an object that implements the Listener interface. In other words, hold all the references you need to remove indirctly in a Listener rather than directly in the session.
Bill
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: executing code when a session expires?