File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Tomcat and the fly likes Cannot run servlets in Tomcat Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Cannot run servlets in Tomcat" Watch "Cannot run servlets in Tomcat" New topic

Cannot run servlets in Tomcat

X V Jay

Joined: Dec 27, 2003
Posts: 6
Hello all,
I have been unable to run servlet using Tomcat 4.1.27. I have put the
class file in WEB-INF\classes. Please tell me where did I go wrong ?
Thank you
X V Jay

Here is the source....
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("Welcome to the Servlet Testing Center");
Here is the web.xml
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE web-app
PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN"
Error message generated....
HTTP Status 404 - /myJspApps/servlet/TestingServlet
type Status report
message /myJspApps/servlet/TestingServlet
description The requested resource (/myJspApps/servlet/TestingServlet)
is not available.

Apache Tomcat/4.1.27
Frank Carver

Joined: Jan 07, 1999
Posts: 6920
You have made an explicit mapping for your servlet in your web.xml, so you don't need the "/servlet" in your URL. Try something like:

Read about me at ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
X V Jay

Joined: Dec 27, 2003
Posts: 6
Thanks Frank. It worked.
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

"X V Jay"-
Welcome to the JavaRanch! Please adjust your displayed name to meet the
JavaRanch Naming Policy.
You can change it
Thanks! and welcome to the JavaRanch!

Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
I agree. Here's the link:
subject: Cannot run servlets in Tomcat
It's not a secret anymore!