Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clean up after sessions end

 
L. Riley
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the need to do some cleanup work after a session ends. In ASP (oh my!) this can be done using session.onEnd in the global.asa.
How can this be done in JSP?
 
mounika paruchuri
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Liz,
do you want to know when the session is destroyed ,that is ends?? If that is the case then check out API documentation for HttpSessionListener interface in package javax.servlet.http
Mounika.
 
L. Riley
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes...I want to clean up some records in a table if the user ends the session. Do you know of another place that describes this more clearly than the API?
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64845
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything you could ever want to know: Java Servlet 2.3 Specification.
hth,
bear
 
Fisher Daniel
Ranch Hand
Posts: 582
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use class which act as session listener in your application and register it in deployment descriptor (web.xml) . It extends HttpSessionListener and implements method sessionCreated(HttpSessionEvent se) and sessionDestroyed(HttpSessionEvent se).
You can put your code for clean up in method sessionDestroyed().
The web container will invoke or notify sessionDestroyed() when your application invalidates sessions or the sessions are timeout.
Hope this help...
Correct me if i am wrong...
daniel
[ April 02, 2003: Message edited by: Fisher Daniel ]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13062
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you make your class that contains the data a SessionBindingListener, the object will be notified when the session is destroyed and you will have the data right there. You don't have to register a SessionBindingListener.
Bill
 
Mehta Saryu
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
session.removeAttribute("sessionname")
 
L. Riley
Greenhorn
Posts: 28
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No...I want to delete some records from a database if the session ends...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic