You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by Jose Oliver <jo...@isoco.com> on 2000/12/12 20:47:08 UTC

url-pattern behaviour

	Hello,

	I'm trying to configure tomcat with some
servlets, and I've found a difference in
behaviour from other servlet engines. I'm trying
to configure it in such a way that requests for
the main page (http://www.blah.blah.com/) are
served by a servlet called StartServlet:

  <servlet-mapping>
    <servlet-name>StartServlet</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>

and it actually does it, but the problem is that
it serves _any_ url that starts with "/", for
example "/images/whateverfooimage.jpg". The
same application running under Dynamo 5.0 does
it ok (for me), since StartServlet only serves
request for "/" url...

	Is this a bug in tomcat? Or is a
"feature" of Dynamo?

	Best,
	Jose

Re: url-pattern behaviour

Posted by "Craig R. McClanahan" <Cr...@eng.sun.com>.
Jose Oliver wrote:

>         Hello,
>
>         I'm trying to configure tomcat with some
> servlets, and I've found a difference in
> behaviour from other servlet engines. I'm trying
> to configure it in such a way that requests for
> the main page (http://www.blah.blah.com/) are
> served by a servlet called StartServlet:
>
>   <servlet-mapping>
>     <servlet-name>StartServlet</servlet-name>
>     <url-pattern>/</url-pattern>
>   </servlet-mapping>
>
> and it actually does it, but the problem is that
> it serves _any_ url that starts with "/", for
> example "/images/whateverfooimage.jpg". The
> same application running under Dynamo 5.0 does
> it ok (for me), since StartServlet only serves
> request for "/" url...
>
>         Is this a bug in tomcat? Or is a
> "feature" of Dynamo?
>

Which version of Tomcat?

The "/" mapping is defined in the servlet spec as "use this servlet only if none
of the other mappings match."  So, if you have JSP pages mapped to the JSP
servlet (in the usual way), the JSP mapping should be used first.

You might also experiment with declaring your servlet as the "welcome file" for
this app.  See the servlet spec
<http://java.sun.com/products/servlet/download.html> for more details.

>
>         Best,
>         Jose

Craig