tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: How can I change the servlet path?
Date Wed, 01 Mar 2000 02:57:41 GMT
Arion wrote:

> Hi!
> The default local path for CONTEXT is <CONTEXT docbase>/web-inf/classes,
> am I right? How can I override the setting say <CONTEXT
> docbase>/servlet?

You are confusing the class path for a context (used to locate all Java
classes referenced by a web application, not just servlet classes) with the
URL that is mapped to a particular servlet.

The 2.2 servlet specification defines that all classes under
WEB-INF/classes (and all JAR files under WEB-INF/lib) become part of the
class path for a particular context.  However, this has nothing to do with
how you access servlets found in those directories via a URL.

If you use a URL like "/{context-path}/servlet/xxxxx", Tomcat looks for a
class named "xxxxx" in one of the above two locations, or along the system
class path if not found there.  It follows the usual Java rules for
resolving classes that are inside packages.

In addition, you can map a servlet to a specific path to a specific servlet
using <servlet-mapping> element in the web.xml file.  Again, the class
itself is located by looking in WEB-INF/classes, WEB-INF/lib/*.jar, or
along the system class path.  See the servlet 2.2 specification for more
details and examples.

> Thank you
> Arion

Craig McClanahan

PS:  Tomcat 3.0 had a bug that prevented classes in WEB-INF/lib/*.jar from
being found.  This has been fixed in more recent releases.

View raw message