tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Servlet Configuration Question
Date Tue, 18 Jul 2000 17:57:51 GMT
Chance Terrell wrote:

> Yes, you have the right directory... and specifing them in the web.xml is
> recommended but optional I believe. (anyone care to confirm or correct me on
> that?)

You can put your servlet classes themselves in WEB-INF/classes, or you can
package them in a JAR file under WEB-INF/lib.  The latter approach is very
useful if your app needs something like a JDBC driver that is already packaged
in a JAR file.

For referencing your servlets in a request, there are two basic approaches to

(1) "Invoker" Capability

Tomcat has built in support that recognizes request URIs like
"/servlet/{classname}" and automatically loads the named class -- you have to
specify the fully qualified class name if it is in a package -- without needing
to explicitly list the servlet in web.xml.

Note that this feature is *not* part of the servlet API standard, but it is very
widely implemented across servlet containers.

(2) Servlet Mapping Capability

All servlet containers that conform to the servlet 2.2 API support the ability
to define servlets in web.xml using the <servlet> tag, and then define
"mappings" to them using the <servlet-mapping> tag.  You can define mappings for
an exact match, for a prefix (send all requests that match "/foo/*" to this
servlet), for a filename extension (this is how JSP pages are sent to the JSP
servlet, for example), or a default servlet that serves any request not assigned
to some other servlet (this is how Tomcat 3.1 serves static files).

Additionally, using a <servlet> element lets you define initialization
parameters.  You can ask the servlet container to load the servlet when it
starts up, as well.

> Chance

Craig McClanahan

> -----Original Message-----
> From:
> [
>]On Behalf Of Melissa Matthews
> Sent: Tuesday, July 18, 2000 8:24 AM
> To:
> Subject: Servlet Configuration Question
> I am a newbie to Tomcat and to servlets.  From what I understand the
> servlets under Tomcat should be in the WEB-INF/classes directory under my
> project root directory.  Is that correct?  Do I need to list all of the
> servlets I am using in the web.xml file?  I am running Apache/Tomcat on
> Windows 2000. Thanks for any help!
> Melissa Matthews
> Cendex Corp
> Phone 703.205.9256
> Fax 703.205.2961

View raw message