You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by John Chan <jc...@verity.com> on 2002/01/08 21:19:10 UTC

Re: Servlet and Web.xml confusion

Hi...


> Hi,
>
> I have tomcat 4.0.1 running on a Redhat 7.1 system.  I can get the
examples
> servlets working, the ones that come with tomcat.
>
> I installed some simple servlets in webapps/ROOT and they work.  I put one
> in
> $CATALINA_HOME/webapps/ROOT/WEB-INF/classes/hello/HelloServlet2.class
>  and invoked it with
> http://localhost:8080/servlet/hello.HelloServlet2
>
> and it worked fine.
>
> I then installed a servlet in
> $CATALINA_HOME/webapps/hello/WEB-INF/classes/hello/HelloWorld2.class
>
> I put the following web.xml file in WEB-INF/web.xml
> <!DOCTYPE....>
> <web-app>
>   <servlet>
>     <servlet-name>HelloWorld2</servlet-name>
>     <servlet-class>HelloWorld2</servlet-class>
>   </servlet>
>
>   <servlet-mapping>
>     <servlet-name>HelloWorld2</servlet-name>
>     <url-pattern>/HelloWorld2</url-pattern>
>   </servlet-mapping>
> <web-app>
>
> and I tried to invoke this servlet with
> http://localhost:8080/hello/servlet/hello.HelloWorld2
>
> but it didn't work.  I get 404 file not found or whatever.
>
> How do I access this servlet?  What am I doing wrong?
>
> Thanks for the help
>
> Dave

I believe that you need to modify the server.xml to add the context. As it
currently stands, Tomcat has no way of knowing that the directory "hello"
actually exists.

The statement to add (at the minimum) would be something like:

          <Context path="" docBase="hello" debug="0"/>.

Anyhow, hope that helps.

John



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>


Re: Servlet and Web.xml confusion

Posted by John Chan <jc...@verity.com>.
Hi...

> I believe that you need to modify the server.xml to add the context. As it
> currently stands, Tomcat has no way of knowing that the directory "hello"
> actually exists.
>
> The statement to add (at the minimum) would be something like:
>
>           <Context path="" docBase="hello" debug="0"/>.
>
> Anyhow, hope that helps.
>
> John

Oops, that would be <Context path="/hello" docBase="hello" debug="0"/>.

John



--
To unsubscribe:   <ma...@jakarta.apache.org>
For additional commands: <ma...@jakarta.apache.org>
Troubles with the list: <ma...@jakarta.apache.org>