Custom 404/403/500 error messages in Tomcat 7

Members, I have tried so many solutions courtesy of google, and none seems to work. I have deployed two apps in tomcat, dspace and geonetwork. I want to set the aforementioned custom error pages for both, at once. So in /etc/tomcat7/web.xml, I added the following (just below <welcome-file-list>): <error-page> <error-code>404</error-code> <location>error/404.html</location> </error-page> <error-page> <error-code>403</error-code> <location>error/403.html</location> </error-page> <error-page> <error-code>500</error-code> <location>error/500.html</location> </error-page> Then I have a folder called error in /var/lib/tomcat7/webapps/. I had tried putting the error folder inside /etc/tomcat7/Catalina/localhost/, still didnt work. What am I missing? With each change, I restart tomcat

1. Just make sure the custom error files are accessible through the root directory. 2. In the location tag add a leading slash to the path On 4/21/16, Peter Karunyu via skunkworks <skunkworks@lists.my.co.ke> wrote:
Members, I have tried so many solutions courtesy of google, and none seems to work.
I have deployed two apps in tomcat, dspace and geonetwork. I want to set the aforementioned custom error pages for both, at once.
So in /etc/tomcat7/web.xml, I added the following (just below <welcome-file-list>):
<error-page>
<error-code>404</error-code>
<location>error/404.html</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>error/403.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>error/500.html</location>
</error-page>
Then I have a folder called error in /var/lib/tomcat7/webapps/.
I had tried putting the error folder inside /etc/tomcat7/Catalina/localhost/, still didnt work.
What am I missing?
With each change, I restart tomcat

Thanks Mr. Obbayi! Got it to work by following your directions: 1. Place the files themselves inside /var/lib/tomcat7/webapps/ROOT/ 2. Make the CSS inline, mine didnt work with external CSS file, but worked fine with inline CSS 3. In /etc/tomcat7/web.xml, have these lines just below <welcome-file-list>: <error-page> <error-code>404</error-code> <location>/404.html</location> </error-page> <error-page> <error-code>403</error-code> <location>/403.html</location> </error-page> <error-page> <error-code>500</error-code> <location>/500.html</location> </error-page> And it works! On Thu, Apr 21, 2016 at 10:32 AM, Steven Obbayi <sobbayi@gmail.com> wrote:
1. Just make sure the custom error files are accessible through the root directory. 2. In the location tag add a leading slash to the path
On 4/21/16, Peter Karunyu via skunkworks <skunkworks@lists.my.co.ke> wrote:
Members, I have tried so many solutions courtesy of google, and none seems to work.
I have deployed two apps in tomcat, dspace and geonetwork. I want to set the aforementioned custom error pages for both, at once.
So in /etc/tomcat7/web.xml, I added the following (just below <welcome-file-list>):
<error-page>
<error-code>404</error-code>
<location>error/404.html</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>error/403.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>error/500.html</location>
</error-page>
Then I have a folder called error in /var/lib/tomcat7/webapps/.
I had tried putting the error folder inside /etc/tomcat7/Catalina/localhost/, still didnt work.
What am I missing?
With each change, I restart tomcat

Awesome Peter. On 4/21/16, Peter Karunyu <pkarunyu@gmail.com> wrote:
Thanks Mr. Obbayi! Got it to work by following your directions:
1. Place the files themselves inside /var/lib/tomcat7/webapps/ROOT/ 2. Make the CSS inline, mine didnt work with external CSS file, but worked fine with inline CSS 3. In /etc/tomcat7/web.xml, have these lines just below <welcome-file-list>: <error-page> <error-code>404</error-code> <location>/404.html</location> </error-page> <error-page> <error-code>403</error-code> <location>/403.html</location> </error-page> <error-page> <error-code>500</error-code> <location>/500.html</location> </error-page>
And it works!
On Thu, Apr 21, 2016 at 10:32 AM, Steven Obbayi <sobbayi@gmail.com> wrote:
1. Just make sure the custom error files are accessible through the root directory. 2. In the location tag add a leading slash to the path
On 4/21/16, Peter Karunyu via skunkworks <skunkworks@lists.my.co.ke> wrote:
Members, I have tried so many solutions courtesy of google, and none seems to work.
I have deployed two apps in tomcat, dspace and geonetwork. I want to set the aforementioned custom error pages for both, at once.
So in /etc/tomcat7/web.xml, I added the following (just below <welcome-file-list>):
<error-page>
<error-code>404</error-code>
<location>error/404.html</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>error/403.html</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>error/500.html</location>
</error-page>
Then I have a folder called error in /var/lib/tomcat7/webapps/.
I had tried putting the error folder inside /etc/tomcat7/Catalina/localhost/, still didnt work.
What am I missing?
With each change, I restart tomcat
participants (2)
-
Peter Karunyu
-
Steven Obbayi