Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Detect session timeout on certain form submits?

843844Oct 9 2009 — edited Oct 12 2009
Hi!

I know there is a lot of discussions and suggestions about timeout handling, but none matches my need quite.

We have a JSF project, which among other things has a certain chain of form pages. That is : user clicks a link and gets to the first form.
There he fills in some data and clicks on the submit button and (if no validation error occur) gets another form page. There he enters some other data, clicks submit and so on, for about 5 pages.


The problem is that if at one step he waits too long and the session expires, our code does not detect it and fails.

Details:
The form data on all pages is saved to a session scoped managed bean. The commandLink action is a method of that bean (different method for each page submit). Later steps use data submitted in previous steps and there it fails in the session times out and the server creates a new session and a new bean (which lacks the data from previously submitted pages).

One way to solve it is to have a check in each method of the bean, but that is a lot of code. Duplicated code for that. Besides the action method thee are also a lot of get methods that are called from the JSF page that also depend on data set by previous pages.

Other way is to use a filter or a phase-listener(see [1] and [2]). It seems better and simpler, but it would require some (hardcoded?) list of pages that should be checked (as opposed to other pages that do not care about session).

There is also the ViewExpiredException, but apparently that does not work with STATE_SAVING_METHOD set to 'client' and that is how our project is set up.

Oh, we use JSF 1.2 (Sun implementation jsf-api-1.2_04-b01-RC1.jar) and also a bit of tomahawk12-1.1.8.jar (for uploading files).


Many thanks for any help,
David (Sun SWCD/SCJP, but very new to JSF)

[1] http://techieexchange.blogspot.com/2008/02/jsf-session-expiry-timeout-solution.html
[2] http://jsweetland.livejournal.com/3229.html
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 9 2009
Added on Oct 9 2009
5 comments
398 views