• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Execute Session Destroying code in jsp

 
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
when my some bean is holding the scope session. and my user does
not properly logs out instead he presses cross button of the browser. directly then how could i log him out.
or if power goes down.
is there any solution other than using timeout?
 
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
there is HttpSessionBindingListener which can be associated to a session , it will notify you when session is expired and started.
or else i dont think there is nothing to notify the events such as browser closing, power off
 
vishal avad
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx manas
my question is how to write a code which will be automatically executed when a session is closed in any of the possible ways
 
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When the session expires (or invalidates), it calls valueUnbound() method on all the bound objects implementing HttpSessionBindingListener. So, you can write a class which implements HttpSessionBindingListener and
have the valueUnbound() method execute the cleanup rutine.
 
vishal avad
Ranch Hand
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thx sanjay
i will try this and get back
thx again

vishal
 
Manas Ahlaad
Ranch Hand
Posts: 165
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi sanjay & avad,
valueUnbound() is called when the session expires , but closing the browser does not let the session expire.
If the browser is closed , the session object stays at the server for quite sometime (the idle time specified for the servlet specified in the web.xml file) , if the instance of the servlet idle upto the time then the server removed the instance from container thus causing the session to expire.
try specifying short time in web.xml file
manas
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic