• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1183
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You cannot put class files in the default package under classes. That might be the problem ./..
 
Ranch Hand
Posts: 664
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 14691
16
Eclipse IDE VI Editor Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

http:/localhost:8080/ch1/Ser1


You mean http:/localhost:8080/ch1/Serv1 ?
 
Jones Iraland
Ranch Hand
Posts: 36
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic