0

I am using JSF and have javax.faces.STATE_SAVING_METHOD to client in web.xml. What I want to happen is, when session times out and I try to redirect to another page, it must redirect to sessionTimeout.jsf and on click of a button on that page, it must redirect to login.jsf. I have designed sessionTimeout.jsf. Whenever session expires and I try to navigate to a different page, javax.faces.application.ViewExpiredException is thrown. I have set a session variable in target page so that everytime it goes to that page, it first checks the variable but here its throwing exception before going to that page. How to solve this ?

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Prabhat
  • 2,261
  • 7
  • 46
  • 74

4 Answers4

1

This could help

Community
  • 1
  • 1
Jose Diaz
  • 5,353
  • 1
  • 31
  • 29
  • I cannot put tag in faces-config.xml and putting it in web.xml wont make any difference – Prabhat Jul 21 '10 at 04:59
  • What JSF implementation are you using, MyFaces, Facelets, Richfaces, etc? – Jose Diaz Jul 21 '10 at 05:12
  • @Prabhat: http://stackoverflow.com/questions/3206922/issue-with-jsf-viewexpiredexception-and-multiple-error-page-tag-definitions-in-we – BalusC Jul 21 '10 at 11:26
1

"Whenever session expires and I try to navigate to a different page, javax.faces.application.ViewExpiredException is thrown."

You should make pages such as error pages and the login page transient, so that the session can be invalidated when navigating away from in-session pages. Thanks to BalusC for the article on this:

http://balusc.omnifaces.org/2013/02/stateless-jsf.html

This will ensure your Session scoped beans don't get re-initialized immediately when invalidating the session in an action method, and redirecting to a view that isn't protected by your session authorization filter.

0

The solution is to add:

<a4j:region>
 <script language="javascript">
 A4J.AJAX.onExpired = function(loc, expiredMsg){
  window.location = "/sessionTimeOut.jsf";
 }
 </script>
</a4j:region>

Read more in RichFaces guide

Dejell
  • 13,947
  • 40
  • 146
  • 229
-2

add to Web.xml give message in page for reloading...

<error-page>
    <exception-type>javax.faces.application.ViewExpiredException</exception-type>
    <location>viewExpired.xhtml</location>
</error-page>
Matt Ball
  • 354,903
  • 100
  • 647
  • 710
TaherT
  • 1,285
  • 2
  • 22
  • 41
  • 2
    Read the other answers and the comments on other answers before unnecessarily posting a duplicate answer. – BalusC Jul 22 '10 at 14:02