This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes JSF and the fly likes Timeout via idlemonitor Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "Timeout via idlemonitor" Watch "Timeout via idlemonitor" New topic
Author

Timeout via idlemonitor

Julian Ivancsuk
Greenhorn

Joined: Mar 20, 2013
Posts: 1
I am trying to handle the session timeout via idlemonitor, a primefaces component.

I am doing this because i need to let the user know that due to inactivity the session has expired. I need to display this message through a dialog, after he closes the dialog he should be redirected to the loginpage. He should not be able to click "back" and browse on the application just as nothing happend; if he clicks "back" he should be redirected to a sessionexpired.xhtml page.

I put the idleMonitor in my loggedintemplate.xhtml, so it works only if you are logged in, no matter on what page, beacause all my pages, after you logged in, derives from the loggedintemplate.xhtml.

This is how the code in my loggedintemplate.xhtml looks like:



So the functionality of this code basically checks if the user was inactive for 6 seconds, if he was inactive, a un-closeable dialog pops up and tells him that the session has expired.

The method loginController.timeout() should log the user out, invalidate the session etc.

My problem is that I don't know how to invalidate the session, how to log out the user etc. If I use FacesContext.getCurrentInstance().getExternalContext() .invalidateSession(); it does invalidate the session, but I need more. For example, if the user is inactive for more than 30 min, the default JavaEE timeout time, i get a nullPointerException.

I want to handle the timeout "manually", is there a way to disable the default JavaEE timeout?

What is the best way to handle the timeout manually, not like this:

Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15629
    
  15

You can set the container session timeout period to be infinite in the web.xml file. I don't remember the details, but they're in the J2EE documentation.

The following item is improper:


The action attribute is a reference to the backing bean's action method, not executable code and should therefore not contain "()".


Customer surveys are for companies who didn't pay proper attention to begin with.
 
 
subject: Timeout via idlemonitor
 
Similar Threads
Session Invalidation and Timeout !
response.senRedirect does not seem to be working in filter
Auto Session logoff
How to read "session-timeout" defined in web.xml
Browser close session destroy