How to run Servlets on Apache tomcat 4.1?

Discussion in 'Web Design & Programming' started by dorai007, Jul 26, 2005.

  1. dorai007

    dorai007 Geek Trainee

    Likes Received:
    0
    Trophy Points:
    0
    Guys, ive got a file testServlet.java(below) .Its a servlet and the problem is i cant view it on apache tomacat server.Ive been getting 404 error persistently.Please some1 tell me how to run servlets and which directory to place them so that i can view them on the server(http://localhost:8080/)

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

    public class testServlet extends HttpServlet {

    public void init(ServletConfig config) throws ServletException
    {
    super.init(config);
    }

    public void doGet(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException
    {
    System.out.println("testing Servlet");

    String name = request.getParameter("name");
    System.out.println("Hello "+name);

    }

    public void destroy()
    { }
    }
     
  2. Sniper

    Sniper Administrator Staff Member

    Likes Received:
    59
    Trophy Points:
    63

Share This Page