• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

"Correct" way to detect timeout in form handling?

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)
 
Ranch Hand
Posts: 132
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
David Balažic
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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).
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic