title: Using Spring MVC 3.1+ WebApplicationInitializer to programmatically configure session-config and error-page
body: <p><a href="http://static.springsource.org/spring/docs/3.1.x/javadoc-api/org/springframework/web/WebApplicationInitializer.html" rel="noreferrer">WebApplicationInitializer</a> provides a way to programmatically represent a good portion of a standard web.xml file - the servlets, filters, listeners. </p>
  
  <p>However I have not been able to figure out a good way to represent these elements(session-timeout, error-page) using WebApplicationInitializer, is it necessary to still maintain a web.xml for these elements?</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;session-config&gt;
      &lt;session-timeout&gt;30&lt;/session-timeout&gt;
  &lt;/session-config&gt;
  
  &lt;error-page&gt;
      &lt;exception-type&gt;java.lang.Exception&lt;/exception-type&gt;
      &lt;location&gt;/uncaughtException&lt;/location&gt;
  &lt;/error-page&gt;
  
  &lt;error-page&gt;
      &lt;error-code&gt;404&lt;/error-code&gt;
      &lt;location&gt;/resourceNotFound&lt;/location&gt;
  &lt;/error-page&gt;
  </code></pre>