File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Soft Skills this week in the Jobs Discussion 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: 16303
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Timeout via idlemonitor