aspose file tools*
The moose likes JSF and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » JSF
Bookmark ""Correct" way to detect timeout in form handling?" Watch ""Correct" way to detect timeout in form handling?" New topic
Author

"Correct" way to detect timeout in form handling?

David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
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:
http://www.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)
Christian Nicoll
Ranch Hand

Joined: Mar 09, 2008
Posts: 106
Hi David,

my first intention was to get the session over the request and then to check with the isNew() if a new session was created or if an "old" valid session was received. I assume that the way with request.getSession(false) is more performant, and so I would use this way.

I don't know if there exists an offical recommendation.


SCJP 5, SCJD 5, SCWCD 5, SCBCD 5, SCJDWS 5
My SCBCD-Notes - My Hello World Webservice
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16145
    
  21

Are you referring to the infamous and much-hated ViewExpiredException?

I'm still working on that one myself, actually. JSF version 2 is supposed to add some features that will help, but apparently they're yet to actually address the problem directly.


Customer surveys are for companies who didn't pay proper attention to begin with.
David Balažic
Ranch Hand

Joined: May 15, 2008
Posts: 86
Tim Holloway wrote:Are you referring to the infamous and much-hated ViewExpiredException?

I don't think so ;-)
I didn't see that Exception (yet).
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: "Correct" way to detect timeout in form handling?