title: Handle exception javax.faces.application.ViewExpiredException
body: <p>I have configured the session expiration in my web.xml.</p>
  <pre><code>&lt;error-page&gt;
      &lt;exception-type&gt;javax.faces.application.ViewExpiredException&lt;/exception-type&gt;
      &lt;location&gt;/xxx.xhtml&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  <p>And in the .xhtml files its meta (in two, the rest of the files inherit from them):</p>
  <pre><code>&lt;meta http-equiv=&quot;refresh&quot; content=&quot;${pageContext.session.maxInactiveInterval};url=xxx.xhtml&quot; /&gt;
  </code></pre>
  <p>In some pages the application works correctly (it is redirected to xxx.xhtml with an expiration warning message), but in many others the following exception is thrown and the application is dead, it gives an error in the log but the user cannot know that has happened, the application simply freezes.</p>
  <pre><code>javax.faces.application.ViewExpiredException: viewId:/[view where the error occurs] - View could not be restored /[view where the error occurs]
  </code></pre>
  <p>Is there a way to filter or catch this error when it occurs anywhere in the application?</p>
  <p>I have placed a breakpoint in the method that is called by the view that throws the error and the application does not stop on it.</p>
  <p>I have a filter</p>
  <pre><code>@WebFilter(&quot;*&quot;)
  </code></pre>
  <p>that is executed correctly when there is an active session and when it is not ignored.</p>
  <p>I have found a considerable amount of information on Stackoverflow, but perhaps too cumbersome.</p>
  <p>There is some way to capture this error &quot;globally&quot;?. Like a servlet filter captures a specific URL, something similar for an exception occurs wherever it occurs within the application.</p>
  <p>Thanks greetings!</p>