You need to do 2 things in your web.xml file: name the servlet and map it to
a URL. Something like the following is what you'll have to do:

<servlet>
    <servlet-name>yourServletName</servlet>
    <servlet-class>your.servlets.fully.qualified.ClassName</servlet-class>
</servlet>

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

The first declaration associates a logical name with the actual fully
qualified class name of the servlet.

The second associates the named servlet with a url pattern to which Tomcat
will respond by invoking the servlet. In your case you want the pattern to
be the root.

Now I am reasoning by analogy with what I know works wherein one maps the
servlet to say /foobar/myServlet. I haven't actually tried running a servlet
from /.

Good luck.
-- 
Tom Woteki, a.k.a. Dr. Wo
mail to:<[EMAIL PROTECTED]>
202-544-2743 (fax)
http://www.woteki.com/wines <-- a pure Java, Apache-Tomcat web application
running under MacOSX


> From: Donie Kelly <[EMAIL PROTECTED]>
> Reply-To: [EMAIL PROTECTED]
> Date: Wed, 21 Feb 2001 06:25:36 -0500
> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
> Subject: RE: Running servlet from /
> 
> Thanks Tom
> How exactly do I do that. My servlet is located in
> /webapps/ROOT/WEB-INF/classes? At the moment I can access it using
> /servlet/serbletName.
> 
> Forgive me, because I'm new to Tomcat but can you show me exactly how to do
> this...
> 
> Thanks in advance
> Donie
> 
> -----Original Message-----
> From:     Tom Woteki [mailto:[EMAIL PROTECTED]]
> Sent:    21 February 2001 01:14
> To:    tomcat user help; Donie Kelly
> Subject:    Re: Running servlet from /
> 
> Map the servlet to an appropriate URL in the web.xml file or make the home
> page into a jsp file.
> 
>> From: Donie Kelly <[EMAIL PROTECTED]>
>> Reply-To: [EMAIL PROTECTED]
>> Date: Tue, 20 Feb 2001 15:10:17 -0500
>> To: "'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>> Subject: Running servlet from /
>> 
>> Hi 
>> 
>> Hi all
>> 
>> I want a servlet to run when I use the URL http://wilson/ <http://wilson/>
>> 
>> i.e., no servlet specified. How can this be easily achieved?
>> 
>> Donie
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [EMAIL PROTECTED]
>> For additional commands, email: [EMAIL PROTECTED]
>> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to