This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSF and the fly likes session expire with JSF Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "session expire with JSF" Watch "session expire with JSF" New topic

session expire with JSF

rashmi coorg

Joined: Jul 11, 2011
Posts: 19
In my jsf application i am making use of richfaces 3.. i track the user logged in and store the user-agent, user id and ip of the logged in system. this is done to prevent the user to login with same browser again with out loggin out. These details are stored in a map when the user loggs in and when user loggs out the entry for that user is removed from the map.. but if the sesssion expires i am not able to remove the user from the map as i am handling session expire with web.xml using the following code:
and in sessionExpired.jsp i am just redirecting the user to login page and here i will not be able to access any bean as the session is expired. so when session expires the user is blocked from loggin in again in same browser. i don't want this to happen. i want to remove the entry of the user from the map. how can this be done?
Kumaravadivel Subramani
Ranch Hand

Joined: Jul 05, 2008
Posts: 166

Is the map has stored in HttpSession object? ( hope so). If it is then create a class which implements HttpSessionListener and have you logic of inserting entry of logged user and remove entry in respective methods of sessionCreated() and sessionDestroyed(). It will work. Hope this will solve your problem.

No pain, No gain.
OCJP 1.6
rashmi coorg

Joined: Jul 11, 2011
Posts: 19
thank you so much.. this works !!
It is sorta covered in the JavaRanch Style Guide.
subject: session expire with JSF
Similar Threads
How to stop multiple login for same userid and password
Restricting multiple logins
Application logout problem
JSF Session Expires on Login Page (how can I prevent it?)
FORM based Declarative Authentication and Session