title: Why doGET is being called instead of doPOST?
body: <p>I am testing the form based Security authentication with Servlet/JSP. I am simply running the servlet directly and it should ask me for the Login authentication as per the web.xml file. But it simply enters the doGET method everytime. And yes, I have made changes to add the "role" 'users' in the tomcat-users.xml file. I am new to J2EE. So please bear with my stupid questions.</p>
  
  <p>Here is the Login.jsp</p>
  
  <pre><code>&lt;form method="post" action="j_security_check"&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;User name: &lt;/td&gt;
          &lt;td&gt;&lt;input type="text" name="j_username"&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Password: &lt;/td&gt;
          &lt;td&gt;&lt;input type="password" name="j_password"&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;`enter code here`
  &lt;input type="submit"    value="Login"&gt;  
  &lt;/form&gt;
  </code></pre>
  
  <p>Here is the Servlet:</p>
  
  <pre><code>@WebServlet("/SecurityCheck")
  public class SecurityCheck extends HttpServlet {
      private static final long serialVersionUID = 1L;
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html");
          response.getWriter().println("I went to doGET");
      }
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
          response.setContentType("text/html");
          response.getWriter().println("success........");
      }
  
  }
  </code></pre>
  
  <p>and here is the web.xml:</p>
  
  <pre><code>&lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;
    &lt;security-constraint&gt;
      &lt;web-resource-collection&gt;
        &lt;web-resource-name&gt;Security check&lt;/web-resource-name&gt;
        &lt;url-pattern&gt;/SecurityCheck/*&lt;/url-pattern&gt;
        &lt;http-method&gt;POST&lt;/http-method&gt;
      &lt;/web-resource-collection&gt;
  
      &lt;auth-constraint&gt;
        &lt;role-name&gt;users&lt;/role-name&gt;
      &lt;/auth-constraint&gt;
    &lt;/security-constraint&gt;
    &lt;login-config&gt;
      &lt;auth-method&gt;FORM&lt;/auth-method&gt;
      &lt;form-login-config&gt;
        &lt;form-login-page&gt;/Login.jsp&lt;/form-login-page&gt;
        &lt;form-error-page&gt;/Faliure.jsp&lt;/form-error-page&gt;
      &lt;/form-login-config&gt;
    &lt;/login-config&gt;
  &lt;/web-app&gt;
  </code></pre>