Blank page instead of tomcat custom error page

My setup: Apache 2.2 + Tomcat 6.0 @Windows 2008 R2 64bit

  • static web pages: /
  • servlet: / foo
  • tomcat and apache linked mod_jk
  • 404.jsp is placed in tomcat \ webapps \ ROOT

cat \ conf \ web.xml:

<error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page> 

apache \ conf \ extra \ HTTPD-ssl.conf:

 JkMount /foo/* worker1 JkMount /404.jsp worker1 

When I open https: //...../404.jsp , my custom error page is displayed. But when I open https: //...../foo/nonexisting.html , a blank page is displayed.

If I remove the <error-page>...</error-page> code from web.xml and open https: //...../foo/nonexisting.html , then tomcats own 404 will be displayed.

Any clues?

+7
tomcat custom-error-pages
source share
7 answers

As far as I can see, webapps errors cannot be handled with error pages hosted in ROOT. Now I put 404.jsp in every webapp (/foo/404.jsp,/bar/404.jsp, ...) and now it works. I can safely remove 404.jsp in ROOT, but if I remove 404.jsp in / foo or / bar, a blank page will be used if 404 occurs either in webapp. Any tomcat ignores the host / location element, or the contents of that element are added to the webapp "call" path.

+1
source share

Jkmount should have a context as a parameter, for example:

 JkMount /mycontext/* worker1 

then the pages are accessed as follows:

 https://mycontext/someservlet/ 

or

 https://mycontext/foo/nonexisting.html 
+2
source share

Note. You must be sure that the page you specify does not start with a number (for example: 404.jsp). This is because, according to Java syntax, you cannot run the class name with a number.

http://www.jguru.com/faq/view.jsp?EID=492774

Hope that helps :-)

0
source share

If it works fine when loading 404.jsp and shows a blank page when tomcat actually tries to use the page to handle 404 error, this may mean that there is an error in the 404.jsp source code that was called only using the errorData object.

Check out the logs. I had a similar problem with a blank page and it turned out that I had the wrong taglib url .

EDIT

In addition, JkMount is not required since tomcat already generates these 404s (i.e. they are not in the Apache offer).

0
source share

I also had this problem, and it turned out that the culprit was that I entered the name of the application context root in the location of the error page. I.e

 <error-page> <error-code>404</error-code> <location>/MyApp/404.jsp</location> </error-page> 

While it certainly was

 <error-page> <error-code>404</error-code> <location>/404.jsp</location> </error-page> 
0
source share

I ran into this problem when starting a static web project. I did the following implementation and it worked for me.

Added the following lines to% CATALINA_HOME% / conf / web.xml

  <error-page> <error-code>404</error-code> <location>/error_404.html</location> </error-page> 
0
source share

It displays exactly 404 pages, and not? Because some other error codes are also used, like 400 401 403 500. Look at this link for this http://docs.yahoo.com/docs/writeus/error.html

If you have others, add these error codes to the web.xml file. Hope this helps. Happy coding ...

-one
source share

All Articles