Win a copy of Terraform in Action this week in the Cloud forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

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
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic