Hi!
In a JSF/Tomcat project, we have a chain of form pages.
The first page sets a few properties of a session scoped managed bean and then calls on submit a method of that same bean.
Then the next page with form is loaded, which sets some other properties of the same bean and on submit calls a different method of that same bean.
If the session times out before this second submit, then the bean method will have the properties from the first page uninitialized.
This condition should be detected and handled by redirecting to another page.
The question is, how to do it?
I googled and found some different approaches:
- in bean code,
test the request.getSession(false) value
- in bean code, misuse one property as an indicator if the prevoius forms were submitted
- declare a filter that checks the session before the
servlet code is called
- declare a
JSF phase listener, that checks for timeout and redirects
Is there a "one true" way? An official recommendation? Good practice?
Regards,
David
Material I found on web:
https://coderanch.com/t/213277/JSF/java/Session-time-out-JSF
http://jsweetland.livejournal.com/3229.html (faces phase listener)
http://techieexchange.blogspot.com/2008/02/jsf-session-expiry-timeout-solution.html (filter)