• 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

Servlets not working under Tomcat

 
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Okay, I did research on this, but alas I need another pair of eyes.
From this page: http://test.javaranch.com/wiki/view?InvokerServlet
In the file conf/web.xml find a section of text that looks like this:
<!-- The mapping for the invoker servlet -->
<!--
<servlet-mapping>
<servlet-name>invoker</servlet-name>
<url-pattern>/servlet/*</url-pattern>
</servlet-mapping>-->
You need to uncomment the servlet-mapping and then restart Tomcat to allow all servlets to work.

Yes, I know that this is a security risk, however since I'm going through a textbook that supplies code for many, many servlets... I don't want to add mapping for each of them since this isn't for production (or even development) but for training purposes. However I find myself in a bind-when I save HelloWorld.java and HelloWorld.class file to root/web-inf/classes and then try to call the servlet by:
http://localhost:8080/servlet/HelloWorld
I get the infamous: The requested resource (/servlet/HelloWorld) is not available.
so, what could be wrong? I should be correct in assuming that by uncommenting the servlet invoker that I should be able to type in: http://localhost ort/servlet/servletName and access the servlet, no?
I've been all over the Jakarta site, and to tell you the honest truth, Java Ranch is a lot more user friendly... which is how I ended up here (again).
I've even tried to place it in the servlets-examples directory, and modified the appropriate web-xml file with the following mapping:
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>HelloWorld</servlet-class>
</servlet>
and even this:
<servlet>
<servlet-name>HelloWorld</servlet-name>
<servlet-class>/servlet/HelloWorld</servlet-class>
</servlet>
But still, no love. Unfortunately, its too late at this hour to head out to the bookstore and reference one of the Sun Core JSP and Servlet texts, so I thought to ask here. Any ideas?
Thanks,
Michael
 
Michael Sullivan
Ranch Hand
Posts: 235
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
well, not sure what to make of this. Went to the bookstore and referenced a couple of texts that note that Tomcat is more difficult to config than the other servers. I tried mapping my servlets with no effect, and changed various server.xml and web.xml settings... also in vain.
I had previously downloaded Resin, and unzipped that, made one slight change to the server.xml file and presto! Servlets working fine. Strange.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Tomcat seems simple to configure to me. It follows the published servlet API exactly.
It is the use of the invoker servlet that has led people astray many times - primarily because earlier versions had it on by default and the introductory books used it.
If you are using the invoker servlet, you don't need to define anything in web.xml but the invoker - just make sure your class files end up in the right place.
Bill
 
brevity is the soul of wit - shakepeare. Tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic