RSS feed

How to Configure 404 Error or Page not Found on Tomcat

Guidelines on Setting Customize Error Page on Tomcat

Published by: San (9/12/2007)

SEP 12 2007

I have tomcat 6.x installed on my Windows 2003, how can I configure 404 error to point my 404.jsp page and compile the java code written into it.

It’s very simple to configure 404 or any other errors to your own jsp or html page. The only file you should modify in this process is web.xml which recites under all the application root folder. Under given code shows how to configure it in general for all the applications running on Tomcat, later on you can add the fourth point to your application only. Your web.xml will be inside WEB-INF folder under the ROOT folder. Updating this file will affect your application only.

1. Open the conf folder under tomcat
2. Open the file web.xml (/tomcat/conf/web.xml)
3. Locate:
<welcome-file-list>
   <welcome-file>default.jsp</welcome-file>
  ……………………..
  ……………………..
</welcome-file-list>
4. Add following lines for the custom error page.
<error-page>
   <error-code>404</error-code>
   <location>/default.jsp</location>
</error-page>

 

How to Email from JSP Page? >>

 

COMMENT

Name: Jo

hey man i don't see your < > ..... </ > tags.

Name: doubt

but where to store the file default.jsp

Name: saket

thankyou very much..

Name: amit

This does not work in tomcat 6.X

Name: Emiliano Heredia

doesn’t work useless

Name: Bacon Bobby

Yes it works on Tomcat 6.0. After the web.xml change, you must set your browser settings in MSIE > Internet Options > Advanced > Show friendly HTTP error messages (uncheck this)

Name: toni

Good!

*Name:
*Comment:
You can use HTML tags here.
*Code: Please enter the sum of 5+2