View Single Post
  #2 (permalink)  
Old 04-27-2009, 04:50 PM
devin devin is offline
Member
 
Join Date: Feb 2009
Posts: 11
Rep Power: 0
devin is on a distinguished road
Default
I remember when I first started working with servlets and tomcat and I was getting 404 errors but I can't remember why.

I tried your servlet mapping and it worked on my version of tomcat, but I am using tomcat5.5. Not sure if something changed with the version you are using.

What is the content of the servlet?

Any errors when you reload the webapp?

Here is the content of the servlet I tried:

package com;

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

/**
* This is a test servlet
*
*/

public class FirstServlet extends HttpServlet {


@Override public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {

response.setContentType("text/html");

PrintWriter out = response.getWriter();

String docType = "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";

String title = "First Servlet";
out.println
(docType +
"<html>\n" +
"<head><title>" + title + "</title></head>\n" +
"<body BGCOLOR=\"#FDF5E6\">\n" +
"<h2>" + title + "</h2>\n" +
"Hey this is the first servlet!"+
"</body></html>");
}

@Override public void doPost(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}


}