Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

On sessiontimeout event?  RSS feed

 
Arvind Subramanian
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • 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.
 
Pravin Shirke
Ranch Hand
Posts: 152
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • 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
 
ujjwal soni
Ranch Hand
Posts: 405
  • Mark post as helpful
  • send pies
  • 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
  • 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...
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to use the HttpSessionListener to achieve it.
 
Bosun Bello
Ranch Hand
Posts: 1511
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should be able to use the HttpSessionListener to achieve it.
 
SmrutiRanjan Patra
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!