aspose file tools*
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
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: 16305
    
  21

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Overriding Tomcat Error Pages with Httpd