This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Overriding Tomcat Error Pages with Httpd

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

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
Saloon Keeper
Pie
Posts: 18276
56
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