You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Moraes, Fabio" <fa...@eds.com> on 2003/08/01 16:52:40 UTC

The same servlet through 2 different URL

SCENE: I'm using Tomcat 4.1.

I want my servlet Principal.class to be called when someone access
http://localhost/projname/ OR http://localhost/projname/index

I put this in webapps/projname/web.xml:

   <servlet>
       <servlet-name>Principal</servlet-name>
       <servlet-class>servlets.Principal</servlet-class>
   </servlet>

and this:

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

Everything works for http://localhost/projname/, but not for
http://localhost/projname/index.

Then, I tried:

   <servlet-mapping>
      <servlet-name>Principal</servlet-name>
      <url-pattern>/</url-pattern>
      <url-pattern>/index</url-pattern>
   </servlet-mapping>

Everything works for http://localhost/projname/index, but not for
http://localhost/projname/.

It seems the last URL-PATTERN tag overwrites the others ...

How could I make it work fine ?

Thanks,

---
 Fabio Moraes
 fabio.moraes@eds.com
 System Engineer
 Work Force Management System
 +55 21 3088 9548