title: tomcat gives 404 error while my mapping in xml is fine
body: <pre><code>public class Guestbook extends CacheHttpServlet {
      /**
       * 
       */
      private static final long serialVersionUID = 1 L;
      private Vector &lt; GuestbookEntry &gt; entries = new Vector &lt; GuestbookEntry &gt; ();
      private long lastModified = 0; // Time last entry was added
      // Display the current entries, then ask for a new entry
      public void doGet(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
          res.setContentType("text/html");
          PrintWriter out = res.getWriter();
          printHeader(out);
          printForm(out);
          printMessages(out);
          printFooter(out);
      }
      // Add a new entry, then dispatch back to doGet()
      public void doPost(HttpServletRequest req, HttpServletResponse res)
      throws ServletException, IOException {
          handleForm(req, res);
          doGet(req, res);
      }
      private void printHeader(PrintWriter out) throws ServletException {
          out.println("&lt;HTML&gt;&lt;HEAD&gt;&lt;TITLE&gt;Guestbook&lt;/TITLE&gt;&lt;/HEAD&gt;");
          out.println("&lt;BODY&gt;");
      }
      private void printForm(PrintWriter out) throws ServletException {
          out.println("&lt;FORM METHOD=POST action='/hello.html'&gt;"); // posts to itself
          out.println("&lt;B&gt;Please submit your feedback:&lt;/B&gt;&lt;BR&gt;");
          out.println("Your name: &lt;INPUT TYPE=TEXT NAME=name&gt;&lt;BR&gt;");
          out.println("Your email: &lt;INPUT TYPE=TEXT NAME=email&gt;&lt;BR&gt;");
          out.println("Comment: &lt;INPUT TYPE=TEXT SIZE=50 NAME=comment&gt;&lt;BR&gt;");
          out.println("&lt;INPUT TYPE=SUBMIT VALUE=\"Send Feedback\"&gt;&lt;BR&gt;");
          out.println("&lt;/FORM&gt;");
          out.println("&lt;HR&gt;");
      }
      private void printMessages(PrintWriter out) throws ServletException {
          String name, email, comment;
          Enumeration &lt; GuestbookEntry &gt; e = entries.elements();
          while (e.hasMoreElements()) {
              GuestbookEntry entry = (GuestbookEntry) e.nextElement();
              name = entry.name;
              if (name == null) {
                  name = "Unknown user";
                  email = "Unknown email";
              }
              email = entry.email;
              comment = entry.comment;
              if (comment == null) comment = "No comment";
              out.println("&lt;DL&gt;");
              out.println("&lt;DT&gt;&lt;B&gt;" + name + "&lt;/B&gt; (" + email + ") says");
              out.println("&lt;DD&gt;&lt;PRE&gt;" + comment + "&lt;/PRE&gt;");
              out.println("&lt;/DL&gt;");
              // Sleep for half a second to simulate a slow data source
              try {
                  Thread.sleep(500);
              } catch (InterruptedException ignored) {}
          }
      }
      private void printFooter(PrintWriter out) throws ServletException {
          out.println("&lt;/BODY&gt;");
          out.println("&lt;/HTML&gt;");
      }
      private void handleForm(HttpServletRequest req,
          HttpServletResponse res) {
          GuestbookEntry entry = new GuestbookEntry();
          entry.name = req.getParameter("name");
          entry.email = req.getParameter("email");
          entry.comment = req.getParameter("comment");
          entries.addElement(entry);
          // Make note we have a new last modified time
          lastModified = System.currentTimeMillis();
      }
      public long getLastModified(HttpServletRequest req) {
          return lastModified;
      }
  }
  class GuestbookEntry {
      public String name;
      public String email;
      public String comment;
  }
  </code></pre>
  
  <p>And in the XML file i used</p>
  
  <pre><code>&lt;web-app&gt;
  &lt;servlet&gt;
  &lt;servlet-name&gt;
  GuestBook
  &lt;/servlet-name&gt;
  &lt;servlet-class&gt;
  Guestbook
  &lt;/servlet-class&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
  &lt;servlet-name&gt;
  GuestBook
  &lt;/servlet-name&gt;
  &lt;url-pattern&gt;
  /hello.html
  &lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>everything i used are fine but tomcat still gives me a 404 error. although i tried by different methods but still it gives me an error.
  if someone will provide a solution then it would be really appreciated.</p>
  
  <p>thanks in advance</p>