• 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Tim Cooke
Sheriffs:
  • Rob Spoor
  • Liutauras Vilda
  • paul wheaton
Saloon Keepers:
  • Tim Holloway
  • Tim Moores
  • Mikalai Zaikin
  • Carey Brown
  • Piet Souris
Bartenders:
  • Stephan van Hulst

Servlet beginners question

 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have installed tomcat 4.0.1 on my machine.
When I run servlet , say http://localhost:8080/chapter01/servlet/HelloWorldServlet , why we give the servlet as a directory under chapter01. There is no direcory called servlet in web-inf direcory. Can somebody help me to understand this?
Thanks
Salima
 
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look at the web.xml file in the web-inf root (thought i've never run this particular example before) there's most likely a servlet maping requests to chapter01/servlet/HelloWorldServlet to the actual servlet name you're looking for.
If you can't find it there, another place to look would be the clases directory under web-inf.
Good luck,
Cory
 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are looking for the directory named 'servlet', it is possible that such may not physically exist. It is part of the default 'mapping' of tomcat looking for servlets under the 'classes' directory.
If you don't wish to use the 'servlet' term in the address path (http://localhost:8080/chapter01/servlet/HelloWorldServlet) to avoid confustion, append (under </servlet> the following servlet-mapping in web.xml if not already there.
...
<servlet-mapping>
<servlet-name>HelloWorldServlet</serlet-name>
<url-pattern>/HelloWorldServlet</url-pattern>
</servlet-mapping>
...
you can then use 'http://localhost:8080/chapter01/HelloWorldServlet'.
Aside from providing a shorter address (less typing), one may have to get used to this <servlet-mapping> because it seems to be the norm for the later versions of tomcat. Tried running a similar servlet in tomcat version 4.1.12 without such configuration in web.xml and it didn't work. Only when the <servlet-mapping> configuration was included did it work.
 
Salima Lalani
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot!!
Salima
 
Trust God, but always tether your camel... to this tiny ad.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic