tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: servlet-mapping with *.suffix problem
Date Sat, 11 May 2002 16:15:32 GMT

On Sat, 11 May 2002, Luuk de Vries wrote:

> Date: Sat, 11 May 2002 17:58:41 +0200
> From: Luuk de Vries <>
> Reply-To: Tomcat Users List <>
> To:
> Subject: servlet-mapping with *.suffix problem
> Hi,
> I have a working application using RedHat
> Linux6.2+jdk.1.3+Apache+mod_jk+tomcat3 which I migrated to the most recent
> RedHat Linux7.2+jdk1.4+Apache+mod_webapp+Tomcat4.0.3.
> After the usual minor problems with migrations, the application worked fine
> again.
> With the exception of the following detail:
> In web.xml I do a servlet-mapping with:
> <servlet-mapping>
>   <servlet-name>Bestel</servlet-name>
>   <url-pattern>/servlet/bestel</url-pattern>
> </servlet-mapping>
> And with:
> <servlet-mapping>
>   <servlet-name>Bestel</servlet-name>
>   <url-pattern>*.slk</url-pattern>
> </servlet-mapping>
> The one with *.slk is not working. I get: "Apache Tomcat/4.0.3 - HTTP Status
> 404 - /raddertc4/servlet/bestel/statistiek.slk".
> And in the log it says: java.lang.ClassNotFoundException: bestel
> When I modify the last mapping to:
> <servlet-mapping>
>   <servlet-name>Bestel</servlet-name>
>   <url-pattern>/servlet/bestel/statistiek.slk</url-pattern>
> </servlet-mapping>
> The results are as they should be.
> As nothing can be found upon this problem in Google/tomcat-user-archive and
> faq, I submit my problem to you.
> Thanks in advance for any suggestion,

You are running into a subtle but important rule in how servlet mappings
work -- there is a priority order that they are checked in:
* Exact match (like your last one)
* Path match (/foo/bar/*)
* Extension match (*.foo)
* Default servlet

Tomcat provides a default mapping for "/servlet/*" to trigger the invoker
servlet, and assumes that the first path segment after the "/servlet/"
part is the name or classname of your servlet.  Because path maps are
checked second, this one is matched before the *.slk mapping.  Thus, it
looks for a servlet named "bestel" and does not find it.

If you try a ".slk" path that does *not* start with "/servlet/", you'll
find that it works as you expect.  Alternatively, you can comment out the
/servlet/* mapping (in $CATALINA_HOME/conf/web.xml) if you don't want the
invoker -- but this is global to all your webapps.

> Luuk de Vries


To unsubscribe, e-mail:   <>
For additional commands, e-mail: <>

View raw message