tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From (Alex Chaffee)
Subject minimum web.xml
Date Tue, 09 May 2000 01:18:43 GMT
Craig McClanahan wrote the below, which I think is very well
written. Craig, please send me email; I'd like permission to add it to
the jGuru Servlet FAQ. (

Unfortunately, "you don't need any web.xml entries at all" seems to be
slightly wrong -- I recently tried making a web.xml file that was
empty ("<webapp></webapp>" IIRC), expecting that it would take all its
settings from the system conf/web.xml. Instead, it failed
completely. Putting a copy of conf/web.xml into WEB-INF/web.xml worked

Can someone elaborate on what the minimum required entries in web.xml

Cheers -

 - Alex

> Second issue -- to make this URL work, you don't need any web.xml entries at all
> -- the only thing you need to do is ensure that your servlet is in a file named
> "myservlet.class" in the WEB-INF/classes directory (or in a JAR file under
> WEB-INF/lib).

> URL mapping is for cases where you want to name your servlet something *other*
> than "/servlet/xxx".  For example, let's say you wanted to use a URL like this:
> (i.e. without the "/servlet" part).  You would put entries like this in web.xml:
>     <servlet>
>         <servlet-name>MyServletName</servlet-name>
>         <servlet-class>com.mysystem.mypackage.MyServlet</servlet-class> 
  // Or
> whatever your Java class name is
>     </servlet>
>     <servlet-mapping>
>         <servlet-name>MyServletName</servlet-name>
>         </url-pattern>/myservlet</url-pattern>
>     </servlet-mapping>
> Note that the servlet name is never visible -- it is just a link between the
> servlet class and the URL pattern(s) that call it.
> Note also that the URL doesn't have to have anything to do with the Java class
> name.  You can use any legal URL pattern that you like, and no one can even tell
> that you're invoking a servlet.

View raw message