Questions tagged [viewexpiredexception]

An exception type that is commonly thrown by the JavaServer Faces (JSF) framework

This exception will be thrown whenever the enduser fires a POST request on a view which does not exist anymore in the server side, because the session has been expired. The view states are by default stored in the session, so they are lost whenever the session expires. A POST request will be fired when the enduser clicks a command button or command link or fires a JSF ajax request.

This can happen when you keep a page open in browser and untouch it for too long so that the session expires (usually, that is 30 minutes, depending on server configuration). Firing a POST request on such a view after session expiration will then result in ViewExpiredException. This can also happen when the browser loads the page from its cache instead of from the server.

They can be handled by <error-page> in web.xml or a custom ExceptionHandler. They can if necessary be avoided by setting the context parameter javax.faces.STATE_SAVING_METHOD to client instead of (default) server which would then save the serialized view state as a hidden input field value of the POST form. With server side state saving, the browser also needs to be instructed to not cache the dynamic JSF pages.

Frequently asked questions:

115 questions
3
votes
1 answer

When does the JSF view state expire?

I believe the following is true if javax.faces.STATE_SAVING_METHOD is set to client, then the view never expires a ViewExpiredException will be thrown if javax.faces.STATE_SAVING_METHOD is set to server and the view state is not available when…
jimmybondy
  • 2,092
  • 3
  • 21
  • 33
3
votes
2 answers

ViewExpiredException when i use @ViewScoped

I have problem with my h:commandButton "Login": when I use @ViewScoped and push this button there is ViewExpiredException, but when I use @SessionScoped, there isn't any error. Stack Trace: javax.faces.application.ViewExpiredException:…
kuba44
  • 1,838
  • 9
  • 34
  • 62
3
votes
3 answers

Can you POST to JSF2 page with an expired session?

I have been using JSF1.2 for login pages. If the user sits on the login page for too long (timeout situatation) and then tries to enter the id and password it fails with ViewExpired error (even though the id/password are correct). This all makes…
JeffJak
  • 2,008
  • 5
  • 28
  • 40
2
votes
2 answers

jsf spring security session timeout viewExpiredException

I have the following problem with the timeouts in Spring Security with JSF: I've customized the sessionmanagement filter so that the user is redirected to the invalidSessionUrl just if the requested page is secured (i.e. if it is allowed just for…
choquero70
  • 4,470
  • 2
  • 28
  • 48
2
votes
2 answers

JSF - set STATE_SAVING_METHOD per-page

I would like to set a particular page (one that does not require a user to sign in to use) to have a STATE_SAVING_METHOD of client rather than server while the rest of the pages use server. Is there a way to set it on a per-page basis? I would like…
OddProblems
  • 201
  • 2
  • 10
2
votes
0 answers

Invoking multiple ajax requests on the same view in a portlet leads to ViewExpiredException

I am working in Portal application build using JSF and Ajax. All the pagecodes are in request scope. We have a page with 2 portlets and in one of the portlet we use ajax to rerender components. When we do such rerendering we are able to modify it 3…
2
votes
2 answers

ViewExpiredException, Page could not be restored

I've tried to follow different posts on how to handle the ViewExpiredException in Mojarra 2.1.0 (with RichFaces 4) on GlassFish 3.1. But what I define in web.xml doesn't seams to have any effect. I use form base security and the user has to logon to…
Chris
  • 712
  • 3
  • 16
  • 39
2
votes
1 answer

Tomcat 7.0.19 and Mojarra 2.1.2 ViewExpiredException

I was using Tomcat 6.0.26 with my project since long time. Now, I need to use EL 2.2 in this project so I moved it to Tomcat 7.0.19 with no other changes (Using Mojarra 2.1.2-b04 with RichFaces 4.0.0). When I start it up, everything is fine until I…
Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72
2
votes
2 answers

JSF 2.0 ViewExpiredException on Glassfish 3.1 when using iframe in Safari

I have a JSF 2.0 web application running on glassfish 3.1 that is working fine on IE, FF, Safari and Chrome. When I added the url of my website inside a iframe of another website then I am getting ViewExpiredException after clicking any button…
Praneeth
  • 1,457
  • 5
  • 23
  • 36
2
votes
1 answer

JSF 2.0 ViewExpiredException

I've been using the JSF 1.2 with the ViewHandler described in this answer : IceFaces Session Expiry causes an exception it was very useful because when the exception occurs the page is automatically regenerated, good for public pages. The problem is…
Alexandre Lavoie
  • 8,711
  • 3
  • 31
  • 72
2
votes
1 answer

What will be the best way of saving faces messages after redirection due to ViewExpiredException?

I followed the following article to deal with ViewExpiredException - Dealing Gracefully with ViewExpiredException in JSF2 It does what it is supposed to do. But I wanted to have some FacesMessage displayed on view if the user was redirected to it…
Bhesh Gurung
  • 50,430
  • 22
  • 93
  • 142
2
votes
1 answer

Preventing ViewExpiredException when clicking broswer back button after session invalidation

I am trying to figure out how to prevent Session Fixation on an JSF login form in Glassfish 3.1. It was easy to do with Servlets, so I am trying to do the same with JSF (based on this question: Retrieving session ID value from a JSF…
Daniel
  • 754
  • 1
  • 11
  • 25
2
votes
1 answer

Handle ViewExpiredException in the background and restore form values

Is there a database-, primefaces- and "keep-session-alive"-free solution to prevent or to handle a ViewExpiredException silently in the background while restoring the form-inputs? for example a user with a "stay logged-in cookie" would prefer not…
Steve
  • 384
  • 1
  • 7
  • 17
2
votes
1 answer

Avoid ViewExpiredException in JSF 1.2 on a single page

I have a login page that is not protected and is accessible via different navigation-cases. The problem: many users access that login page and leave it open for a while before then sign in again. Boom! The terrible ViewExpiredException occurs! I…
pmartin8
  • 1,545
  • 1
  • 20
  • 36
2
votes
3 answers

Enforce javax.faces.application.ViewExpiredException for testing application

I would like to test my webapplication (JSF 2.2) which has a custom Esxception Handler Factory. Now i would like to know if everything works as expected when a javax.faces.application.ViewExpiredException is thrown. Is there any way, I can decrease…