File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Jones Iraland
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could you post your directory structure ? It's hard to glimpse from your message what exactly the problem is. ..
 
Jones Iraland
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1183
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You cannot put class files in the default package under classes. That might be the problem ./..
 
Nabila Mohammad
Ranch Hand
Posts: 661
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Christophe Verré
Sheriff
Pie
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
http:/localhost:8080/ch1/Ser1

You mean http:/localhost:8080/ch1/Serv1 ?
 
Jones Iraland
Ranch Hand
Posts: 36
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 12
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic