By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,779 Members | 1,122 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,779 IT Pros & Developers. It's quick & easy.

Usage of error-page element in web.xml for Tomcat 4.1.24

P: n/a
Hi

Tomcat seems to be completely ignoring any resource that I specify in
an <error-page> directive in the web.xml. The same webapp works under
4.0. Is there a bug in 4.1 that I'm not aware of? I'm simply throwing
a javax.servlet.ServletException in my servlet code and I have the
following directive in the web.xml:

<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>

My browser is just showing me it's own "500 - Internal Error" page,
not what ExceptionHandlerServlet should be serving.

I've checked that ExceptionHandlerServlet is accessible as a resource.

Is there a newsgroup that's more dedicated to problems with Tomcat?

Thanks

Tim
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Jangley wrote:
Hi

Tomcat seems to be completely ignoring any resource that I specify in
an <error-page> directive in the web.xml. The same webapp works under
4.0. Is there a bug in 4.1 that I'm not aware of? I'm simply throwing
a javax.servlet.ServletException in my servlet code and I have the
following directive in the web.xml:

<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>

My browser is just showing me it's own "500 - Internal Error" page,
not what ExceptionHandlerServlet should be serving.

I've checked that ExceptionHandlerServlet is accessible as a resource.

Is there a newsgroup that's more dedicated to problems with Tomcat?

Thanks

Tim

Hi Tim,
I suspect this could be caused by the change in Tomcat 4.1 in the way the
default mapping of servlets is handled.
You can do servlet mapping in the deployment descriptor (web.xml file) so
that a certain URL pattern will invoke a certain servlet of your choice.
Servlet mapping enables you to decide what URL pattern a servlet can be
called with. However, it was optional to perform mapping with Tomcat prior
to version 4.1.12. In the "old" days, if you deployed your servlet in the
"classes" directory under WEB-INF and you didn't map it, your user could
invoke it using this URL:

http://localhost/myApplication/servlet/class-path

And, you didn't even need a deployment descriptor if you didn't mind having
such URLs. This is thanks to Tomcat's invoker servlet that invokes every
servlet not mapped with a URL.
Starting with Tomcat 4.1.12, the invoker servlet is no longer available by
default in all Web apps because the <servlet-mapping> element is commented
out. This was done for security reasons.

Have a look for more detailed explanation at :

http://www.fawcette.com/javapro/2002...efault_pf.aspx

Hope this helps solving your problem.
Brgds, Herman
--
Suse Linux Professional 8.1 on Athlon 1.1 Ghz 512 Mb
Anti Spam = remove the "dot" and the "at"
Registered Linux User #264690
Visit us : http://users.skynet.be/herman.timmermans
Jul 17 '05 #2

P: n/a
Thanks Herman

I'm already enabling anonymous servlets using a mapping for the
invoker. Here's my web.xml:

<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd">

<web-app>

<servlet>
<servlet-name>ProgramaticErrorHandlingServlet</servlet-name>
<servlet-class>chapter7.ProgramaticErrorHandlingServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>DeclarativeErrorHandlingServlet</servlet-name>
<servlet-class>chapter7.DeclarativeErrorHandlingServlet</servlet-class>
</servlet>

<servlet>
<servlet-name>ExceptionHandlerServlet</servlet-name>
<servlet-class>chapter7.ExceptionHandlerServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>

<error-page>
<error-code>500</error-code>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>

<error-page>
<exception-type>javax.servlet.ServletException</exception-type>
<location>/servlet/ExceptionHandlerServlet</location>
</error-page>
</web-app>

It never works with 4.1.24 - I just keeping getting IE's standard 'The
page cannot be displayed' messages. It seems there must be something
fundamentally wrong - I can't find any reference to this kind of
problem on the web and functionally the above example is about as
simple as it can get...
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.