title: HTTP method POST is not supported by this URL using java httpservlet on tomcat
body: <p>I keep getting HTTP method POST is not supported by this URL when calling my httpservlet through an html form. I can't see where I'm going wrong.  I'm running this on a Tomcat server.  Thanks in advance.</p>
  
  <p>The servlet is supposed to print a set of random numbers to the browser.</p>
  
  <p>Here is my servlet:</p>
  
  <pre><code>package servlets;
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.Iterator;
  import java.util.TreeSet;
  
  import javax.servlet.ServletException;
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import utilities.RandNumSet;
  
  public class RandomServlet extends HttpServlet {
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
  public RandomServlet() {
      // TODO Auto-generated constructor stub
  }
  
  @Override
  protected void doGet(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {
      doPost(req, resp);
  
  }
  
  @Override
  protected void doPost(HttpServletRequest req, HttpServletResponse resp)
          throws ServletException, IOException {
  
      PrintWriter out = resp.getWriter();
      resp.setContentType("text/html");
      TreeSet&lt;Integer&gt; randNum = RandNumSet.generateRandNumSet();
      Iterator&lt;Integer&gt; iterator = randNum.iterator();
      String numString = "";
      while (iterator.hasNext()){
          numString = numString + iterator.next() + " ";
      }
  
  
      out.println("&lt;head&gt;");
      out.println("&lt;title&gt;");
      out.println("Your Random Numbers!");
      out.println("&lt;/title&gt;");
      out.println("&lt;/head&gt;");
      out.println("&lt;body&gt;");
      out.println("&lt;h1&gt; Your Random Numbers! &lt;/h1&gt;");
      out.println("&lt;h1&gt; "+ numString + " &lt;/h1&gt;");
      out.println("&lt;/body&gt;");
  }
  
  }
  </code></pre>
  
  <p>Here is the calling html form snippet:</p>
  
  <pre><code>&lt;div id ="form"&gt;
      &lt;form action="RandomServlet" method="post"&gt;
          &lt;input type="submit" value="Randomize!"/&gt;
      &lt;/form&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>Here are the web.xml snippets</p>
  
  <pre><code>    &lt;servlet&gt;
          &lt;display-name&gt;RandomServlet&lt;/display-name&gt;
          &lt;servlet-name&gt;RandomServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;servlets.RandomServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
  
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;RandomServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/RandomServlet&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  </code></pre>