Two Laptop Bag*
The moose likes Tomcat and the fly likes Overriding Tomcat Error Pages with Httpd Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Overriding Tomcat Error Pages with Httpd" Watch "Overriding Tomcat Error Pages with Httpd" New topic
Author

Overriding Tomcat Error Pages with Httpd

Alan Pouton
Greenhorn

Joined: Dec 17, 2013
Posts: 1
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

Joined: Jun 25, 2001
Posts: 15960
    
  19

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: Overriding Tomcat Error Pages with Httpd
 
Similar Threads
apache (tomcat) not parsing XML file?
reference to external error-page
Preventing Apache bridge failure error page
Custom error page
Why is Apache serving the uncompiled page?