Since this is originally my post, and I now understand why/how this works, I
think I'll share with the Tomcat community at-large.
I found an excellent book on the topic of servlets, which goes into a lot
more detail than any of the online Tomcat documentation that I've read with
regard to the configuration files. The book is called "Inside Servlets" by
Dustin R. Callaway.
Basically, the location of servlets, the way I understand it depends on
several factors. First, if the servlets are being handled through a web
server such as Apache there can be some directory aliasing going on, which
can confuse the issue. So instead of confusing things I'll stick with what
Tomcat does.
Tomcat uses "Contexts" which are defined in server.xml. You may be able to
use the admin function in Tomcat to define, view, modify or delete contexts.
However, "Contexts" look to me like a way of saying 'here is where you'll
find servlets'. Basically a context contains a doc base and path, such as
$TOMCAT_HOME/examples. If you register a particular context, then put
servlets in there, you invoke them through your browser as
http://localhost/examples/servlet/classname.
The "servlet" portion of the URL is important, as this is one way that
Tomcat knows to invoke a servlet. There are other ways in which to
configure Tomcat so you don't have to use /servlet in your URL and I'll
include them in a later post.
----- Original Message -----
From: "Cato, Christopher" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 30, 2001 12:40 AM
Subject: RE: It worked - Can someone explain why?
> Take a look at your web.xml for the directory mappings.
>
> The coreservlets.name is merely a pointer to coreservlets/name.class i
> guess.
>
> > -----Original Message-----
> > From: Charles Webber [mailto:[EMAIL PROTECTED]]
> > Sent: den 30 augusti 2001 03:36
> > To: [EMAIL PROTECTED]
> > Subject: It worked - Can someone explain why?
> >
> >
> > I am working through a book on servlets and JSPs. JSPs and
> > beans are pretty
> > easy, and I understand how things fit together - still want
> > to work on some
> > JDBC stuff, but that's later.
> > In the meantime, I wrote a servlet as part of a package
> > called coreservlets.
> > I finally went through the examples that came with Tomcat and
> > noticed in the
> > source that it didn't use packages and figured out both how
> > to invoke my
> > servlets and where to place the class file so that it would work. The
> > question is why it works this way - what is going on under the covers?
> > I placed my servlet class file in a directory like
> > $TOMCAT_HOME/webapps/examples/WEB-INF/classes/coreservlets/nam
> > e.class. On
> > the URL in my browser, I typed in the following:
> > http://host/examples/servlet/coreservlets.name - and it worked!!!
> > So the confusion I have is due to the fact that the directory
> > path names
> > don't match where the servlet is located. Can anyone explain
> > this? I'm
> > sure this is pretty straightforward - and if some document points this
> > ut - if you could point me to that I'll take it from there.
> > Thanks.
> >