Win a copy of Rust Web Development this week in the Other Languages 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
  • Ron McLeod
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Jesse Silverman
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Frits Walraven

On sessiontimeout event?

 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In our website when the user logout, we will log the activity. but some users will not logout manually and after a while the session gets timeout , in this scenario we cant able to log the activities. is it possilbe to handle the session timeout event in the servlet? we are using tomcat as our container.
 
Ranch Hand
Posts: 152
Eclipse IDE Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi arvind,
i think you should use listener for this task. find out something about HttpSessionListener. i think it will the serve the purpose for u.
Hope it helps
Bye
 
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
For an application that isn't using container based authentication, I was able to use the following filter. I have another application which uses container based security. In that application, I put the checks in my login servlet, so that it optionally displays text stating that the session expired on the login page. Basically, what the code does is looks for a session ID in the incoming request and if it isn't a valid session ID, it acts on it.

// SessionExpiredFilter.java


// web.xml

 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Soni i have already done the login design based on this only. Problem now is when the user logout , i will log data. So this function occurs when user manually logout but if the session got expired then that operation is not getting carried out. so is there any possible to handle session timout event , so that i can able to do the required operation on that event.

I got the blog about listener, i must read about that and try. if any one have alternative or implemented this scenario please share...
 
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to use the HttpSessionListener to achieve it.
 
Bosun Bello
Ranch Hand
Posts: 1512
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should be able to use the HttpSessionListener to achieve it.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi arvind,

We can do this by writing one class SessionTiemOutTest that implements the HttpSessionListner interface and we need to do the listner set up in the web.xml. like

In the SessionTiemOutTest class we need to implement both the method in the httpSessionListner interface. We need to write the code in the sessionDestroyed(HttpSessionEvent event) method of SessionTiemOutTest class when session timeout or invalidate.

Thanks & regards,
Smruti
reply
    Bookmark Topic Watch Topic
  • New Topic