On 17/10/2010 16:04, Sylvain Laurent wrote:
> Indeed, that's the problem I'm facing.
> After spending some time reading the spec and the comments in both bug 
> reports, I'm inclined to believe that the current behavior of tomcat 7.0.4 is 
> not spec compliant.
> 
> I created a webapp that matches the example given in chapter 10.10 (Welcome 
> files) of the spec. The files are the same, and my web.xml is like this :
> 
> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"; 
> xmlns="http://java.sun.com/xml/ns/javaee"; 
> xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; 
> xsi:schemaLocation="http://java.sun.com/xml/ns/javaee 
> http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"; id="WebApp_ID" 
> version="2.5">
>   <display-name>testWelcomeFiles</display-name>
>   <welcome-file-list>
>     <welcome-file>index.html</welcome-file>
>     <welcome-file>default.jsp</welcome-file>
>   </welcome-file-list>
>   <servlet>
>     <description></description>
>     <display-name>MyDefaultServlet</display-name>
>     <servlet-name>MyDefaultServlet</servlet-name>
>     <servlet-class>test.MyDefaultServlet</servlet-class>
>   </servlet>
>   <servlet-mapping>
>     <servlet-name>MyDefaultServlet</servlet-name>
>     <url-pattern>/</url-pattern>
>   </servlet-mapping>
> </web-app>
> 
> 
> All the behaviors described in the spec are OK except this one :
>       A request URI of /catalog/products/ will be passed to the “default” 
> servlet, if any.

The example in the spec is wrong. It doesn't follow the rules set out
above the example.

<quote>
The Web server must append each welcome file in the order specified in
the deployment descriptor to the partial request and check whether a
static resource in the WAR is mapped to that request URI. If no match is
found, the Web server MUST again append each welcome file in the order
specified in the deployment descriptor to the partial request and check
if a servlet is mapped to that request URI.
</quote>

There are no matches for the static files so all is OK for the first
sentence. However there is a match (to *.jsp) the second time through so
Tomcat passes "/catalog/products/default.jsp" to the JSP servlet which
returns a 404.

> Despite having declared a default servlet (as defined in section 12.2), it 
> was not called when requesting catalog/products/ and I got a 404 instead...

As per the spec.

Yes, this is stupid but it is what the spec requires.

Tomcat can't tell the difference between a Servlet that expects to be
backed by a static resource and one that does not so can't make a
reasonable decision on what to map and what not. It this behaviour is
disabled, other apps will break in the opposite direction - e.g. a
struts app the uses index.do as a welcome file.

The best solution to this is probably a configuration option (disabled
by default?) that requires welcome files to be backed by static
resources. Could be a global or a per context option. The rules for
mapping welcome files are in the Mapper which does have access to the
Context but should really access it via reflection since o.a.tomcat
isn't meant to depend on o.a.catalina. Maybe handle it at mapper creation?

Mark

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to