Reputation: 492
My setting: Apache 2.2 + Tomcat 6.0 @ Windows 2008 R2 64bit
tomcat\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 an empty 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 is displayed.
Any hints?
Upvotes: 7
Views: 14889
Reputation: 15
I have faced this issue while running a static web project.I have done the following implementation, and it has worked for me.
Added the following lines in %CATALINA_HOME%/conf/web.xml
<error-page>
<error-code>404</error-code>
<location>/error_404.html</location>
</error-page>
Upvotes: 0
Reputation: 198
The Jkmount should have the context as parameter, ex:
JkMount /mycontext/* worker1
then the pages are accessed this way:
https://mycontext/someservlet/
or
https://mycontext/foo/nonexisting.html
Upvotes: 2
Reputation: 492
As far as i can see it, webapps' errors can't be handled with error pages placed in ROOT. I now put the 404.jsp in every webapp (/foo/404.jsp, /bar/404.jsp, ...) and now it works. I can safely delete the 404.jsp in ROOT, but if I delete the 404.jsp in /foo or /bar a blank page is served if a 404 occurres in either webapp. Either tomcat ignores the leading / in the "location" element or the content of this element is appended at the 'calling' webapp's path.
Upvotes: 1
Reputation: 1882
I had this problem as well, and it turns out the culprit was that I'd typed the name of the application context root into the error page location. That is,
<error-page>
<error-code>404</error-code>
<location>/MyApp/404.jsp</location>
</error-page>
Whereas it should of course have been
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
Upvotes: 0
Reputation: 1046
If it works fine when loading 404.jsp, and shows a blank page when tomcat actually tries to use the page to handle a 404 error, it could mean that there is an error in 404.jsp's source code that's only triggered by using the errorData object.
Check the logs. I was having a similar blank page problem and it turned out that I had an incorrect taglib URL.
EDIT
Also, JkMount should not be necessary since tomcat is already generating these 404s (i.e. they are not in Apache's purview).
Upvotes: 0
Reputation: 2528
Note: You need to be sure that the page you specify does not begin with a number (i.e.: 404.jsp). This because, according to Java Syntax, you cannot start a class name with a number.
http://www.jguru.com/faq/view.jsp?EID=492774
Hope that helps :-)
Upvotes: 0
Reputation: 3989
Its shows exactly 404 page not found or else? Because some other error codes also avail like 400,401,403,500. Have a look at this link for this http://docs.yahoo.com/docs/writeus/error.html
If you have any other add that error codes aslo in web.xml file. Hopes this helps. Happy coding...
Upvotes: -1