• 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

Getting started with Servlets

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am having trouble getting started with my own Servlets on my own Tomcat installation. I can get the Tomcat Welcome Page, the Tomcat Manager page and the examples that come with the Tomcat distribution, but if I try do some simple examples from any of the books, for instance Head First Servlets & JSP, I get resource not found.

Specifically
http://localhost:8080/ch1/Serv1
produces
HTTP Status 404
The requested resource (/ch1/Serv1) is not available.

Some specifics.
I have Tomcat 5.5
Here is my implementation of the very first example in Head First.
I deployed this without using a .war
This is the structure under webapps
ch1/
WEB-INF/
web.xml classes/
Ch1Servlet.class


my java class:

Here is my web.xml

I haven't done anything to the Tomcat setup. I believe the server is correctly set-up to deploy .wars Here is the section of the server.xml

I also tried the "SimpleServlet" example offered from a link on the forum page http://simple.souther.us/index.html

The Tomcat Manager shows that for the ch1 and SimpleSrevlet Running is false

I have gone over every aspect I could think of and I am obviously missing something basic.

Any help will be appreciated.
[ February 21, 2007: Message edited by: Michael Zellmann ]
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
At least in JBoss you have to include the extension .WAR to the directory you want to use as an exploded web-app. Don't know if it's the same in Tomcat standalone, but JBoss uses Tomcat... So try it. Rename ch1 dir to ch1.WAR
 
Ranch Hand
Posts: 63
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You don't need the .war extension with tomcat.
For what I see your servlet is in the default package.. If it's not, you have to write the fully qualified name of the servlet class in the web.xml.
Pablo.
 
Michael Zellmann
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies. I did try ch1.war, but to no avail. The ch1 directory is automatically generated when I drop the ch1.war into my webapps directory, so I think it is correct for Tomcat. You are also right that my Servlet is in the default package. I did that just to help make sure I wasn't mis-entering the qualified name. Still no luck.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Michael Zellmann:

The Tomcat Manager shows that for the ch1 and SimpleSrevlet Running is false



That means your web app hasn't started. No amount of standing on your head is going to make the servlet respond if the app isn't running.

You need to find out why the app won't start.

Anything interesting in the logs?
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
P.S. Please use UBB code tags when posting code. Read this for more info.
 
Michael Zellmann
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the replies. Now I understand the code tag and will use that in the future. I figured out the problems (by looking through the logs !) Tomcat logs hadn't been saying anything about my ch1 deployment and everything else that I expected to work was working, so I didn't read the entire log. It turns out that another app that I had tried to deploy didn't work, and it was still in webapps. Apparaently, everytime Tomcat would be started, it would load the other applications (from the Tomcat distribution), but when it got to my problem app, it had an exception because of missing class files. As a consequence, it "skipped inmstalling application listeners because of previous error(s)" I guess that meant it wouldn't pay attention to the ch1 deployment. I successfully deployed ch1 on my Glassfish, and on my public ISP, so I knew it worked. When I removed the other incorrect application from webvapps and Tomcat was able to start without exception, then ch1 worked fine.
 
You know it is dark times when the trees riot. I think this tiny ad is their leader:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic