Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Testing First Servlet....please help

 
Gina Mein
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
I am trying to test my very first servlet on Tomcat 4. I am following the instructions written in the book 'More Servlets and JSP' by Marty Hall.
I compiled the 'HelloServlet.java' file . Now I am supposed to move this file in a location
"install_dir/webapps/ROOT/WEB-INF/classes"
My problem is that there is no "classes" directory under WEB-INF , so where should I put the 'HelloServlet.class' file?
I am a novice in Servlets...so please help....
Thanks
 
taash mg
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Gina

According to what i understand u should make a directory "classes" under ur webapps/ROOT/WEB-INF/ called classes and then put ur files in that directory. Try it out
Cheers
Taash
SCJP2
 
Gina Mein
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks taash.
I created the 'classes' directory under web-inf and placed 'HelloServlet.class' there.
Now when I try to access 'http://localhost:8080/servlet/HelloServlet
it gives me the following error:
Apache Tomcat/4.0.3 - HTTP Status 404 - /servlet/HelloServlet
type Status report
message /servlet/HelloServlet
description The requested resource (/servlet/HelloServlet) is not available.
What should I do to run the servlet? Please Help...
 
taash mg
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HI Gina,
i had the same problems earlier but then i realised i was putting my files in the wrong directory. When u have have installed Tomcat it makes 2 directories on ur disk. one is Apache-tomcat 4.0... and the other is jakarta-tomcat-4.0.3 whatever.. u have to make ur classes folder in the webapps of the jakarta folder and then try
i hope u have done that
Cheers
Taash
 
Gina Mein
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!Taash,
I have installed Tomcat 4.0.3, which is the latest version available. It created only one directory i.e. jakarta-tomcat-4.0.
I renamed the above folder to tomcat4 and have put my class file in c:\tomcat4\webapps\Root\Web-inf\classes.
But the servlet does not work. Can you shed any light on how to make this work?
Thanks.
Gina
 
taash mg
Ranch Hand
Posts: 106
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Gina,
yeah it creates only one directory-Apache-Tomcat-4. u r right.
Secondly have u put the servlet.jar in the classpath . try doing that. i am also new to tomcat but hope this helps
Cheers
Taash
 
mary nathan
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Gina
you can go through the following link.
http://www.moreservlets.com/Using-Tomcat-4.html
thanks
mary
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic