You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Scott D. Anderson" <sa...@wellesley.edu> on 2004/07/19 23:01:35 UTC

simple HelloWorld example -> 404

I'm a novice and I'm working through the Tomcat documentation.  
(I'm using Tomcat 5.)  I've gotten to step 3, 

http://localhost:8080/tomcat-docs/appdev/deployment.html

I'd previously compiled the "HelloWorld" example from the O'Reilly book on 
Java Servlet Programming by Hunter.  I then wanted to run it from the 
browser, so I set up something like the servlets-examples that also has a
HelloWorldExample, so I did the following:

1. created a "foo" directory under $CATALINA_HOME/webapps
2. created a WEB-INF directory under "foo"
3. created a "classes" directory under WEB-INF
4. copied the HelloWorld.java and HelloWorld.class files to
the "classes" directory and made them world readable.
5. chmod all directories 755
6. created a web.xml file from tomcat-docs/appdev/web.xml.txt
7. created an index.html file under "foo" that has a hyperref to 
"servlet/HelloWorld"
8. restarted Tomcat

I checked the log files and I've eliminated the parsing errors for the
web.xml file.  I'm able to visit the index.html file, but when I click on
the
link to "servlet/HelloWorld" I get a 404. 

Note that the web.xml.txt file says that I should be able to execute my
servlet just by accessing localhost:8080/foo/servlet/HelloWorld, yet I'm 
not able to do so.  I think that means that the problem isn't in my web.xml
file (even though that's the most complicated and error-prone step).

I also tried putting the HelloWorld.* files in
webapps/ROOT/WEB-INF/classes,
as directed in the Hunter book, but that didn't work either (404).

Anyone have any ideas on how to get this very simple example working?

Thanks,

Scott

--
Scott D. Anderson
Computer Science Department
Wellesley College
Scott.Anderson@acm.org

 






---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: simple HelloWorld example -> 404

Posted by Schalk Neethling <sc...@volume4.co.za>.
Where is your web.xml located? And if it is located inside foo/WEB-INF/ 
then have you tried accessing the servlet when you remove the web.xml?

Scott D. Anderson wrote:

>I'm a novice and I'm working through the Tomcat documentation.  
>(I'm using Tomcat 5.)  I've gotten to step 3, 
>
>http://localhost:8080/tomcat-docs/appdev/deployment.html
>
>I'd previously compiled the "HelloWorld" example from the O'Reilly book on 
>Java Servlet Programming by Hunter.  I then wanted to run it from the 
>browser, so I set up something like the servlets-examples that also has a
>HelloWorldExample, so I did the following:
>
>1. created a "foo" directory under $CATALINA_HOME/webapps
>2. created a WEB-INF directory under "foo"
>3. created a "classes" directory under WEB-INF
>4. copied the HelloWorld.java and HelloWorld.class files to
>the "classes" directory and made them world readable.
>5. chmod all directories 755
>6. created a web.xml file from tomcat-docs/appdev/web.xml.txt
>7. created an index.html file under "foo" that has a hyperref to 
>"servlet/HelloWorld"
>8. restarted Tomcat
>
>I checked the log files and I've eliminated the parsing errors for the
>web.xml file.  I'm able to visit the index.html file, but when I click on
>the
>link to "servlet/HelloWorld" I get a 404. 
>
>Note that the web.xml.txt file says that I should be able to execute my
>servlet just by accessing localhost:8080/foo/servlet/HelloWorld, yet I'm 
>not able to do so.  I think that means that the problem isn't in my web.xml
>file (even though that's the most complicated and error-prone step).
>
>I also tried putting the HelloWorld.* files in
>webapps/ROOT/WEB-INF/classes,
>as directed in the Hunter book, but that didn't work either (404).
>
>Anyone have any ideas on how to get this very simple example working?
>
>Thanks,
>
>Scott
>
>--
>Scott D. Anderson
>Computer Science Department
>Wellesley College
>Scott.Anderson@acm.org
>
> 
>
>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>  
>

-- 
Kind Regards
Schalk Neethling
Web Developer.Designer.Programmer.President
Volume4.Development.Multimedia.Branding
emotionalize.conceptualize.visualize.realize
Tel: +27125468436
Fax: +27125468436
email:schalk@volume4.co.za
web: www.volume4.co.za
 
This message contains information that is considered to be sensitive or confidential and may not be forwarded or disclosed to any other party without the permission of the sender. If you received this message in error, please notify me immediately so that I can correct and delete the original email. Thank you.



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: simple HelloWorld example -> 404

Posted by Wendy Smoak <ja...@wendysmoak.com>.
From: "Scott D. Anderson" <sa...@wellesley.edu>
> when I click on the link to "servlet/HelloWorld" I get a 404.

Examples with /servlet/ in the URL usually depend upon the Invoker Servlet
being enabled.  It is now disabled by default, and although it's more
frustrating in the beginning, it's better to leave it that way and learn to
configure your Servlets.

http://jakarta.apache.org/tomcat/faq/misc.html#evil

> Anyone have any ideas on how to get this very simple example working?

Put <servlet> and <servlet-mapping> tags into web.xml, and then access the
Servlet using the URL that you configured, NOT the one with /servlet/ in it.
Check the DTD for the required order of tags in web.xml.

-- 
Wendy Smoak


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org