0

I would like to display a single(custom) web page when tomcat encounters different errors such as 403, 404, 405 etc. I have tried with the below solutions.

I have pasted my custom error.html in the prweb folder in webapps folder and pasted the below code in web.xml

<error-page>
<location>$Catalina_home/WEB-INF/webapps/prweb/error.html</location>
</error-page>

Output : Tomcat didn't launch my app and directly displayed 404 error page.

I have pasted my custom error.html in the WEB-INF folder in webapps folder and pasted the below code in web.xml

<error-page>
<location>./error.html</location>
</error-page>

Output : Tomcat didn't launch my app and directly displayed 404 error page.

Can anyone please help me where I went wrong?

laltin
  • 1,134
  • 12
  • 20

1 Answers1

0

You can use error-page with exception-type or error-code .

Also you can define an error page for all only with a specified Servlet version (3.0 I think).

please check this also

How to specify the default error page in web.xml?

And you may have used an invalid page url! you can use "/WEB-INF/..." if you are not sure about it.

  • I am using Tomcat 8.5 which holds the servlet of v3.0. For suppose I've put my error.html file in tomcat-8.5/WEB-INF folder, can you please help me what exactly is the path I have to provide in in web.xml? – hemanth kumar Jul 15 '18 at 14:21
  • Usually the IDE recommend you when you type /WEB-INF. – mehran monster Jul 15 '18 at 15:04
  • As I'm using notepad, there will not be such recommendations. In other posts, I have read that path has to be "$Catalina_home/WEB-INF/error.html" or as I've pasted the file in WEB-INF, path can be "./error.html" but both of them didn't work.Can anyone please provide the exact path that needs to be specified if my file is in WEB-INF folder(main folder not in webapps/appnfolder). – hemanth kumar Jul 16 '18 at 06:59
  • I think it's not too hard to find it. Generate the war file and browse it. You can see where is the error.html – mehran monster Jul 16 '18 at 09:15