Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Clean up after sessions end  RSS feed

 
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?
 
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?
 
Author and ninkuma
Marshal
Posts: 66783
168
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
 
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 ]
 
Author and all-around good cowpoke
Rancher
Posts: 13078
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
 
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...
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!