title: Java Servlet 404 error
body: <p>My system has Tomcat seven and all the files are under webapps. The file structure is </p>
  
  <p>webapps/ WelcomeForm/ web/ WelcomeForm.html</p>
  
  <p>WEB-INF/ web.xml</p>
  
  <p>lib/ classes/ hello/ HelloWorldServlet.java HelloWorldServlet.class</p>
  
  <p>The web folder holds WelcomeForm.html.</p>
  
  <p>WEB-INF holds the web.xml.</p>
  
  <p>lib holds servlet-api.jar and</p>
  
  <p>classes holds HelloWorldServlet.java.</p>
  
  <p>the html file runs fine but I cannot run the Java file as it returns the message:</p>
  
  <pre><code>HTTP Status 404 - /hello
  
  type Status report
  
  message /hello
  
  description The requested resource (/hello) is not available.
  </code></pre>
  
  <p>The code for the files is below:</p>
  
  <p>WelcomeForm.html</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;Welcome Form&lt;/title&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
      &lt;/head&gt;
      &lt;body&gt;
             &lt;form method="POST" action="/hello"&gt;
          &lt;font size="10" color="red"&gt;Hello World!&lt;/font&gt;&lt;BR&gt;
  
       Type your first name and click submit button &lt;input TYPE=TEXT NAME="username" SIZE=20&gt;
              &lt;P&gt;&lt;input type="submit" value="Submit"&gt;
  
  
         &lt;/form&gt; 
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>web.xml</p>
  
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="3.0" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;HelloWorld&lt;/servlet-name&gt;
          &lt;servlet-class&gt;hello.HelloWorldServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;HelloWorld&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/hello&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;session-config&gt;
          &lt;session-timeout&gt;
              30
          &lt;/session-timeout&gt;
      &lt;/session-config&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>HelloWorldServlet.java</p>
  
  <pre class="lang-java prettyprint-override"><code>package hello;
  
  import java.io.IOException; 
  import javax.servlet.ServletException; 
  import java.io.*;
  import javax.servlet.*;
  import javax.servlet.annotation.*;
  import javax.servlet.http.*;
  import javax.servlet.http.HttpServlet; 
  import javax.servlet.http.HttpServletRequest; 
  import javax.servlet.http.HttpServletResponse; 
  import java.io.PrintWriter;
  
  public class HelloWorldServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
        throws ServletException, IOException {
      response.setContentType("text/html");
  
        doPost(request,response);
        }
  
     public void doPost(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException {
      String name = request.getParameter("username");
      PrintWriter out = response.getWriter();
      out.write("Your Name is :" );
      out.print(name);
  
    }    
  }
  </code></pre>
  
  <p>What am I doing wrong?</p>