Results 1 to 2 of 2
  1. #1
    siddharth is offline Member
    Join Date
    Aug 2013
    Rep Power

    Default Apache Tomcat can not find the requested servlet, shows HTTP status 404

    Hi all,

    I wrote a simple servlet file and its web.xml file , reading from the book head_first java. I created a directory tree structure under existing Tomcat 6.0 directory i.e C:\Program Files\Apache Software Foundation\Tomcat 6.0\webapps\ch1\WEB-INF\classes. I placed the Ch1Servlet.class file in the classes directory and web.xml in the WEB-INF directory, then I put the url - http://localhost:8080/ch1/serv1 in the browser but it shows HTTP Status 404 - /ch1/serv1, The requested resource (/ch1/serv1) is not available.
    I also made an index.html file and placed in ch1 directory and tried to access it and it was accessible but could not access the servlet file. I don't know what's the problem.
    Someone please tell me how to resolve it.
    Thanks in advance

    Here is my servlet code.

    Java Code:
    import javax.servlet.*;
    import javax.servlet.http.*;
    public class Ch1Servlet extends HttpServlet
     public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException
      PrintWriter out = response.getWriter();
      java.util.Date today = new java.util.Date();
      out.println("<html> "+
    			  "<body>" +
    			  "<h1 align=center>HF\'s Chapter1 Servlet</h1>"+
    This is web.xml

    Java Code:
    <?xml version="1.0" encoding="UTF-8" ?>
    <web-app xmlns=""
     <servlet-name>Chapter1 Servlet</servlet-name>
     <servlet-name>Chapter1 Servlet</servlet-name>

  2. #2
    gimbal2 is offline Just a guy
    Join Date
    Jun 2013
    Rep Power

    Default Re: Apache Tomcat can not find the requested servlet, shows HTTP status 404

    Try putting the servlet in a package.
    "Syntactic sugar causes cancer of the semicolon." -- Alan Perlis

Similar Threads

  1. Replies: 2
    Last Post: 08-08-2013, 04:14 AM
  2. HTTP Status 500 error with apache tomcat server
    By raazu in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 06-22-2011, 06:29 AM
  3. HTTP Status 404-The requested resource is not available.
    By DeViLHuNTeR in forum Java Servlet
    Replies: 17
    Last Post: 03-11-2011, 02:40 PM
  4. Replies: 1
    Last Post: 12-02-2008, 12:23 AM
  5. HTTP Status 404 - Servlet action is not available
    By onceuponatime in forum Java Servlet
    Replies: 1
    Last Post: 12-11-2007, 04:29 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts