You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Michael P. McCutcheon" <mi...@value.net> on 2000/08/21 15:52:11 UTC

Can't run hello world

I've made a simple hello world type of servlet.  I've added a mike
directory, and in it a WEB_INF directory.  In that directory, I have a
web.xml file:

<?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>MikeTest</servlet-name>
  <servlet-class>Test1</servlet-class>
 </servlet>
 <servlet-mapping>
  <servlet-name>MikeTest</servlet-name>
  <url-pattern>/test</url-pattern>
 </servlet-mapping>
</web-app>

and a classes directory which has a compiled version of:

import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class Test1 extends HttpServlet {
 public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
  res.setContentType("text/html");
  PrintWriter out = res.getWriter();

  out.println("<html>");
  out.println("<head>");
  out.println("<title>");
  out.println("Test1 Servlet");
  out.println("</title>");
  out.println("</head>");
  out.println("<body>");
  out.println("Hello World!");
  out.println("</body>");
  out.println("</html>");

 }
}

I have also changed the server.xml file and added the following:

      <Context path="/mike"
                  docBase="webapps/mike"
                  debug="0"
                  reloadable="true" >
      </Context>

When I goto:

http://localhost:8080/mike/servlet/test

I keep getting a:

404 error.

Why is this?

What must I do to get my simple servlet to work?

Thanks,

Mike