title: HTML form method POST calls java servlet doGet method
body: <p>I have an HTML form like this:</p>
  
  <p>form.html:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
  
   your name is :&lt;br&gt;&lt;br&gt;
  
  &lt;form ACTION="../post2" METHOD="POST"&gt;
  &lt;input name="name" type="text" id="name"/&gt;
  &lt;input name="send"  type="submit"  value="send"/&gt;
  &lt;/form&gt;
  
  &lt;/body&gt;
  &lt;html&gt;
  </code></pre>
  
  <p>The servlet to serve this request:</p>
  
  <p>post2.class:</p>
  
  <pre><code>import java.io.IOException;
  import java.io.PrintWriter;
  import javax.servlet.http.*;
  
      public class post2 extends HttpServlet
      {
  
  protected void doDo(HttpServletRequest request,HttpServletResponse response) 
   throws IOException{
  
  String name = request.getParameter("name");
  
  response.setContentType("text/html");
  PrintWriter out = response.getWriter();
  
  out.println("&lt;HTML&gt;&lt;BODY&gt;");
  out.println("&lt;H2&gt;hello "+name+"&lt;/H2&gt;");
  out.println("&lt;BR&gt;&lt;BR&gt;");
  out.println("info:");
  out.println("&lt;BR&gt;&lt;BR&gt;");
  out.println("&lt;H2&gt;metoda GET&lt;/H2&gt;");
  out.println("&lt;BR&gt;&lt;BR&gt;");
  out.println("SERVER_NAME="+request.getServerName()+"&lt;BR&gt;");
  out.println("REQUEST_METHOD="+request.getMethod()+"&lt;BR&gt;");
  out.println("QUERY_STRING="+request.getQueryString()+"&lt;BR&gt;");
  out.println("REMOTE_HOST="+request.getRemoteHost()+"&lt;BR&gt;");
  out.println("REMOTE_ADDR="+request.getRemoteAddr());
  out.println("&lt;/BODY&gt;&lt;/HTML&gt;"); 
  }
  
  
  @Override
  public void doGet(HttpServletRequest request,HttpServletResponse response) 
  throws IOException {      
   doDo(request,response);
  }
  
  @Override
  public void doPost(HttpServletRequest request,HttpServletResponse response) 
  throws IOException {
   doDo(request,response);
  }
  
  }
  </code></pre>
  
  <p>and the result is :</p>
  
  <pre><code>hello null
  
  
  info:
  
  SERVER_NAME=localhost
  REQUEST_METHOD=GET
  QUERY_STRING=null
  REMOTE_HOST=127.0.0.1
  REMOTE_ADDR=127.0.0.1 
  </code></pre>
  
  <p>what is wrong ? For me it seems that the servlet don't see post method from form. Please help, Im completly have no idea why it not working properly...</p>
  
  <p>the result from the wireshark:</p>
  
  <blockquote>
    <p>648   126.229267  87.105.184.89   192.168.1.100   HTTP    557 POST /post2
    HTTP/1.1  (application/x-www-form-urlencoded)</p>
    
    <p>953   379.456916  192.168.1.100   87.105.184.89   HTTP    239 HTTP/1.1 302 Moved
    Temporarily</p>
    
    <p>955   379.462518  192.168.1.100   87.105.184.89   HTTP    470 GET /post2/
    HTTP/1.1 </p>
    
    <p>957   379.463979  192.168.1.100   87.105.184.89   HTTP    431 HTTP/1.1 200 OK 
    (text/html)</p>
  </blockquote>
  
  <p>routing logic:</p>
  
  <p><code>tomcat\webapps\ROOT\form.html</code> --> <code>\tomcat\webapps\post2\WEB-INF\classes\post2.class</code></p>