Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Newbie servlet issues

 
Sasikanth Malladi
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I have installed the Tomcat server and am using Coreservlets book to get along.
In chapter 2, section 8 (2.8 Test Your Setup), I'm running into issues.

Basically what I'm doing is this: I've created a servlet that generates the string "Hello" and can be displayed when this servlet is invoked via a browser. I have successfully compiled this servlet (with Eclipse) and deployed my HelloServlet.class into my C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ROOT\WEB-INF\classes directory.

However, when I invoke this via http://localhost:8080/servlet/HelloServlet, I'm getting Error 404.

What could I be missing here?

Here's my code: (default package (please don't frown))


Thanks,
Sashi
 
Sasikanth Malladi
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To answer my own question, I had not enabled the invoker servlet as it was throwing out exceptions.

When I enable the invoker servlet in web.xml, I get exceptions based on the following:
Caused by: java.lang.IllegalArgumentException: Servlet mapping specifies an unknown servlet name invoker

Did I miss the invoker servlet during installation? I think not, as I'm pretty confident that I did a fairly clean installation. How do I verify that the invoker servlet is present?

Thanks,
Sashi

P.S. I know that this is more a tomcat specific issue and not really related to JSP/Servlets but I hope someone can answer my Q.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The book you're reading is excellent but is becoming a bit outdated.

It is strongly recommended by most everyone (including the creators of Tomcat) that you never uncomment the Invoker servlet. Instead, start out right from the beginning with explicit servlet mappings in your deployment descriptor.

For more on the invoker servlet see:
http://faq.javaranch.com/view?InvokerServlet


If a working "Hello, World" app would help you to get acquainted with Tomcat and servlet development, I have one on my site that you can have running in seconds (3 mouse clicks if you've already got Tomcat running on your machnie).

Go to http://simple.souther.us and follow the directions for SimpleServlet

This example has an explicit mapping for the one servlet in the application.
 
Sasikanth Malladi
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That helped, Ben.
Thanks.
Sashi
 
Joe Harry
Ranch Hand
Posts: 10123
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ben, the website helped me too!
 
Sasikanth Malladi
Ranch Hand
Posts: 175
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For anyone in future who might come across this post via a search:

It's true that the Core Servlet books are a bit dated. If you have any questions about information in these books, make sure to check www.coreservlets.com for quick answers.

The authors do an admirable job of keeping the website updated.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic