tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <Craig.McClana...@eng.sun.com>
Subject Re: Error 404 - Location:/servlet/MyClass
Date Wed, 03 May 2000 20:05:38 GMT
Christoph Kukulies wrote:

> On Wed, May 03, 2000 at 11:34:14AM -0700, Craig R. McClanahan wrote:
> > Christoph Kukulies wrote:
> >
> > > I added a <Context> entry in server.xml with the purpose to
> > > establish a 'more friendly' path to put my servlet development into
> > > and not to have to move my servlets into places where Tomcat has
> > > it's demos and other stuff.
> > >
> > > So I added
> > > <Context path="/servlets" docBase="webapps/servlets" debug="0" reloadable="
> > > true" >
> > >
> >
> > OK, what you've done here is set up a new web application, with "webapps/servlets"
> > as the document root directory.
> >
> > >
> > > correspondingly to a previous line which was already there
> > > for path="/test".
> > >
> > > Then I put all my classes into /usr/local/build/tomcat/webapps/servlets
> > > but trying to invoke
> > > http://192.168.1.119/servlets/MyClass
> > >
> > > results in an Error 404 (coming from Tomcat). Tomcat.log
> > > shows:
> > >
> >
> > This is not going to work, for two different reasons.  First, you need to put your
> > servlet classes under the WEB-INF/classes directory inside your webapp -- so they
> > would go into:
> >
> >     /usr/local/build/tomcat/webapps/servlets/WEB-INF/classes
> >
> > Second, there is an interesting subtlety:  the location of the servlet's class file
> > has absolutely nothing to do with the URL by which you access it from a browser.
 By
> > default, Tomcat sets up an "invoker" servlet that can access servlets you haven't
> > registered in your web.xml file, so you would be able to do this:
> >
> >     http://192.168.1.119/servlets/servlet/MyClass
> >
> > or, you can set up a "web.xml" file that maps a different URL altogether to this
> > servlet.  For details on this, and what kinds of things go in the WEB-INF
> > subdirectory of a web application, see the Servlet API Specification (you can
> > download it from <http://java.sun.com/products/servlet>).
> >
> > Craig McClanahan
> >
>
> Thanks! Thanks! And thanks again!  This was very enlightening.
> Really. After a hard day I'm finally there. My Web Application - a
> couple of html files and classes are running again! Gotta get me this
> Servlet API. Is it probably servlet2_2-spec.pdf ?

That's the one.  Just be sure you've got the one that says "Final Release" on the front
cover, not one of the earlier public drafts.

> Then I have it
> already. Thought all the time this WEB-INF stuff was a Tomcat
> peculiarity.
>

Nope ... that stuff is standard now.  The good news is that web applications are much
more portable between servlet containers under 2.2 than was ever possible before.

Craig McClanahan



Mime
View raw message