title: Exception and error handling configuration through web.xml
body: <p>I am using Apache MyFaces and need to handle ViewExpiredException differently than other internal server errors.But I find that if I include error-code, 500; then in ViewExpiredException error also it takes the path of error-code.</p>
  
  <p>Below is web.xml configuration:</p>
  
  <pre><code>&lt;error-page&gt;
      &lt;exception-type&gt;javax.faces.application.ViewExpiredException&lt;/exception-type&gt;
      &lt;location&gt;/login.xhtml?faces-redirect=true&lt;/location&gt;
  &lt;/error-page&gt; 
  
  &lt;error-page&gt;
      &lt;error-code&gt;500&lt;/error-code&gt;
      &lt;location&gt;/error.xhtml&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>
  
  <p>How to ensure that i can redirect to different URL for the above two case?
  Referred <a href="https://stackoverflow.com/questions/2237434/multiple-error-code-configuration-web-xml">multiple error-code configuration web.xml</a> and I am fine to replace the location with a single servlet; but how to capture the error in servlet?</p>