This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.

Only 44 hours left in the trailboss' kickstarter!

New rewards and stretch goals. CLICK HERE!

Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Overriding Tomcat Error Pages with Httpd  RSS feed

Alan Pouton
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I'm trying to override a tomcat error page with apache httpd pages based on the http status code in the response. I do not want to use error pages in the war file specified in the web.xml. I only need the error code from the application. This is done using HttpServletResponse.sendError();.

Unfortunatly in nearly every situation, the tomcat error is displayed.

The code contains the following:

ProxyErrorOverride on

ErrorDocument 404 "Not found 404"
ErrorDocument 500 "Internal Server Error 500"
ErrorDocument 503 "Temp Unavailable 503"

This works in an environment where ProxyPass, ProxyPassRevere, ProxyPassReverseCookiePath are used.

However, when no reverse proxy is specified, I cannot get apache to override the tomcat prepared error pages.

Any suggestions would be greatly appreciated.
Tim Holloway
Posts: 18531
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the JavaRanch, Alan!

I don't really see the virtue of that - in fact a lot of times the difference between the Tomcat 404 and Apache 404 pages has clued me in to proxying problems. However...

Probably the simplest way to "replace" these pages is to simply steal copies of the Apache page templates, put them into your WAR and set the error page resource locations in WEB-INF/web.xml.

Note that even in straight Apache without Tomcat those pages are merely defaults and can be (and often are) replaced by custom error pages.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!