title: Why use a JSF ExceptionHandlerFactory instead of <error-page> redirection?
body: <p>All of the <code>ExceptionHandlerFactory</code> examples I have come across so far redirect a user to a <code>viewExpired.jsf</code> page in the event that a <code>ViewExpiredException</code> is caught:</p>
  
  <pre><code>public class ViewExpiredExceptionExceptionHandler extends ExceptionHandlerWrapper {
      private ExceptionHandler wrapped;
  
      public ViewExpiredExceptionExceptionHandler(ExceptionHandler wrapped) {
          this.wrapped = wrapped;
      }
  
      @Override
      public ExceptionHandler getWrapped() {
          return this.wrapped;
      }
  
      @Override
      public void handle() throws FacesException {
          for (Iterator&lt;ExceptionQueuedEvent&gt; i = getUnhandledExceptionQueuedEvents().iterator(); i.hasNext();) {
              ExceptionQueuedEvent event = i.next();
              ExceptionQueuedEventContext context = (ExceptionQueuedEventContext) event.getSource();
  
              Throwable t = context.getException();
              if (t instanceof ViewExpiredException) {
                  ViewExpiredException vee = (ViewExpiredException) t;
                  FacesContext facesContext = FacesContext.getCurrentInstance();
                  Map&lt;String, Object&gt; requestMap = facesContext.getExternalContext().getRequestMap();
                  NavigationHandler navigationHandler = facesContext.getApplication().getNavigationHandler();
                  try {
                      // Push some useful stuff to the request scope for use in the page
                      requestMap.put("currentViewId", vee.getViewId());
                      navigationHandler.handleNavigation(facesContext, null, "/viewExpired");
                      facesContext.renderResponse();
                  } finally {
                      i.remove();
                  }
              }
          }
  
          // At this point, the queue will not contain any ViewExpiredEvents. Therefore, let the parent handle them.
          getWrapped().handle();
      }
  }
  </code></pre>
  
  <p>It seems to me that the following simple <code>web.xml</code> configuration is fundamentally the same and a lot simpler:</p>
  
  <pre><code>&lt;error-page&gt;
      &lt;exception-type&gt;javax.faces.application.ViewExpiredException&lt;/exception-type&gt;
      &lt;location&gt;/viewExpired.jsf&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p>This prompts the question - why would one use an <code>ExceptionHandlerFactory</code>?</p>