Win a copy of Five Lines of Code this week in the OO, Patterns, UML and Refactoring forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Installing servlet

Posts: 21
  • Mark post as helpful
  • send pies
  • 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.
Saloon Keeper
Posts: 22248
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
Additionally you should invoque your servlet like this:
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
  • 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:
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
Thread Boost feature
    Bookmark Topic Watch Topic
  • New Topic