• 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

Installing servlet

 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I apologize in advance for the newbie question...
I'm running Tomcat 4.01 on Windows 98. I compiled a servlet under JDK 1.3.1. I have placed the class file in the appropriate subdirectory (%tomcat%/webapps/HelloWorld/web-inf/classes) and I used the Manager app to install the servlet. Now, when I do "http://localhost:8080/HelloWorld", I get one of those pages that looks like an online ftp listing. It shows the HelloWorld class, but for some reason, it won't run the servlet.
Any ideas what I'm doing wrong? It seemed so simple.
I'm about 75% sure that I set up the path correctly, because Tomcat at least KNOWS what the servlet's name is.
Thanks,
Kevin
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yup. Because it's a servlet, you need to set up an entry in WEB-INF/web.xml that associates the URL logical name to a particular Java class via a servlet's logical ID (servlet-name)
For example:
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Kevin:
Additionally you should invoque your servlet like this:
http://localhost:8080/app_name/servlet/HelloWorld
the app_name is the name you used in the <Context> tag.
I hope to help you..
 
Ranch Hand
Posts: 3695
IntelliJ IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
the only reason I'm updating this 2 years later, is that
1) someone referred to it in a more recent post.
2) it's wrong.

Because the servlet is mapped, it's inappropriate to have /servlet in the URL. This is a mixup of two different techniques.

Either do NOT provide a mapping, and use the invoker servlet (which is NOT recommended), in which case the url is: http://localhost:8080/app_name/servlet/HelloWorld

The preferred method is to provide a mapping, and for the demonstration shown above, the url is:
http://localhost:8080/app_name/HelloWorld
or
http://localhost:8080/app_name/helloworld
 
reply
    Bookmark Topic Watch Topic
  • New Topic