aspose file tools*
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
Author

Cannot run servlets in Tomcat

X V Jay
Greenhorn

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.io.*;
import java.util.*;
public class TestingServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<HEAD>");
out.println("<TITLE>Servlet Testing</TITLE>");
out.println("</HEAD>");
out.println("<BODY>");
out.println("Welcome to the Servlet Testing Center");
out.println("</BODY>");
out.println("</HTML>");
}
}
================================================================
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"
"http://java.sun.com/j2ee/dtds/web-app_2_2.dtd">
<web-app>
<servlet>
<servlet-name>TestingServlet</servlet-name>
<servlet-class>TestingServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>TestingServlet</servlet-name>
<url-pattern>/TestingServlet</url-pattern>
</servlet-mapping>
</web-app>
=======================================================================
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
Sheriff

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:
/myJspApps/TestingServlet


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

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

Joined: Feb 05, 2001
Posts: 17260
    
    6

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


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot run servlets in Tomcat