tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <>
Subject Re: Error 404 - Location:/servlet/MyClass
Date Wed, 03 May 2000 18:34:14 GMT
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
> 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:


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:

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 <>).

Craig McClanahan

View raw message