File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Head First Servlets and JSP - My first servlet Program is not running Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Head First Servlets and JSP - My first servlet Program is not running" Watch "Head First Servlets and JSP - My first servlet Program is not running" New topic
Author

Head First Servlets and JSP - My first servlet Program is not running

Jones Iraland
Ranch Hand

Joined: Sep 15, 2007
Posts: 36
Hi,
I started studying for SCWCD

I brought the 2nd edition of Head First Servlets and JSP.

Alas..I typed the first program in page 30 sample servlet program called "Ch1Servlet"

I followed each step according to the book but it does not run as book says.

I have to create a new folder inside Tomcat 5.0 folder and save my work.
But if i put my program in servlet example folder which is insatalled with Tomcat and if i change that web.xml ,my program runs.


Have any of you got an idea what's happenning?


Thanks & Regards,

Jones
Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
Could you post your directory structure ? It's hard to glimpse from your message what exactly the problem is. ..


JDBCSupport - An easy to use, light-weight JDBC framework -
Jones Iraland
Ranch Hand

Joined: Sep 15, 2007
Posts: 36
Hi,
Sorry about.

I had to create a directory structure under this C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\

called / ch1 / WEB-INF /classes

I put my class file in WEB-INF /classes
while i put web.xml file in WEB-INF

This is the servlet java


My web.xml is






i type http:/localhost:8080/ch1/Ser1 in broweser ,which gives me errors


when i put my class file in

C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\servlets-examples\WEB-INF\classes and edit web.xml in


C:\Program Files\Apache Software Foundation\Tomcat 5.0\webapps\servlets-examples\WEB-INF

and run http://localhost:8080/servlets-examples/servlet/Ser1 ,this is fine.





Sebastian Janisch
Ranch Hand

Joined: Feb 23, 2009
Posts: 1183
You cannot put class files in the default package under classes. That might be the problem ./..
Nabila Mohammad
Ranch Hand

Joined: Nov 05, 2007
Posts: 661
I think in this case you can directly put it under Classes folder.
I guess that's the way I had done it earlier.


Try
Change the encoding to ISO-8859-1 and see if it works.


The future belongs to those who believe in the beauty of their dreams.Dream BIG!
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

http:/localhost:8080/ch1/Ser1

You mean http:/localhost:8080/ch1/Serv1 ?


[My Blog]
All roads lead to JavaRanch
Jones Iraland
Ranch Hand

Joined: Sep 15, 2007
Posts: 36
Yes i meant Serv1.
I typed it incorrectly.

When I put the class file into defualt directory in tomcat it works.but when i do as said in the book it does not
swati soni
Greenhorn

Joined: Aug 16, 2009
Posts: 12
I tried it. Its working fine . I had to struggle through it ,to make the work exactly the way told in the book. Please check your environmant variables set correctly . It might create some problem.

Please do exactly as written . It works fine.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Head First Servlets and JSP - My first servlet Program is not running