This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Tomcat and the fly likes Customize 404 errors in Apache Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Customize 404 errors in Apache Tomcat" Watch "Customize 404 errors in Apache Tomcat" New topic

Customize 404 errors in Apache Tomcat

John Bruso

Joined: Dec 16, 2005
Posts: 1
One would think the answer to this question is all over the web. But honestly, I can't find any good answers.

I want to customize (or redirect) the 400-500 errors running on my apache tomcat server.

Oddly, the current 404 message is blank.. doesn't even say 404??

The source of the page is:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>

I've edited the web.xml file here at the very bottom and restarted the server:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\web.xml




Do I need to move this file to somewhere else, like under the webapps directory?

Also, I placed the error404.jsp page isnide this directory:
C:\Program Files\Apache Software Foundation\Tomcat 5.5\conf\Catalina\localhost

So, I'm lost... thank you for your help.

Ben Souther

Joined: Dec 11, 2004
Posts: 13410

Each application running under Tomcat will have it's own web.xml file (located under the WEB-INF directory.

The location entry will list the location of the JSP relative to the root of the application.

Example (assuming your app is named "MyApp"):

When Tomcat starts up, it scans the webapps directory for war files or properly constructed directory structures and deploys them as web applications.

Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
I agree. Here's the link:
subject: Customize 404 errors in Apache Tomcat