Share

November 17, 2008

Tomcat Servlet 2.4 simple 404 Page

So i moved one of my sites from ASP.net to Servlet/JSP pages and had a need to make sure all my request for my old pages do not get lost.

Here is my simple 404 salution.

create a web.xml (if you don't have one) in WEB-INF.

<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/j2ee" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">
    <error-page>
        <error-code>404</error-code>
        <location>/</location>
    </error-page>

    <session-config>
        <session-timeout>30</session-timeout>
    </session-config>
</web-app>