title: Cannot access doPost after clicking on Submit
body: <p>i am trying to create a simple login page using .jsp and servlet. I cannot seem to trigger the doPost method after clicking on the button in my form at LogIn.jsp. My code is as shown:</p>
  
  <p>LogIn.jsp</p>
  
  <pre><code>    &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  
  &lt;html&gt;
      &lt;head&gt;&lt;title&gt;LogIn JSP Page&lt;/title&gt;&lt;/head&gt;
      &lt;body bgcolor="white"&gt;
          &lt;h1&gt;LogIn JSP Page&lt;/h1&gt;
          &lt;form action="CheckLogIn" method="POST"&gt;
              &lt;table&gt;
                  &lt;tr&gt;
                      &lt;td align="right"&gt;Member ID:&lt;/td&gt;
                      &lt;td align="left"&gt;&lt;input type="text" name="memId" length="30"/&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td align="right"&gt;Password:&lt;/td&gt;
                      &lt;td align="left"&gt;&lt;input type="text" name="pw" length="30"/&gt;
                      &lt;/td&gt;
                  &lt;/tr&gt;
              &lt;/table&gt;
              &lt;p&gt;&lt;input type="submit" value="Log In"/&gt;&lt;/p&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CheckLogIn.jsp</p>
  
  <pre><code>&lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  
  &lt;html&gt;
      &lt;head&gt;
          &lt;title&gt;CheckLogIn JSP Page&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Check LogIn&lt;/h1&gt;
          &lt;%
              String data=(String)request.getAttribute("data");
          %&gt;
          &lt;table&gt;
              &lt;tr&gt;
                  &lt;td align="left"&gt;&lt;%=(String)data%&gt;&lt;/td&gt;
              &lt;/tr&gt;
          &lt;/table&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>LibrarySystemServlet.java</p>
  
  <pre><code>    public class LibrarySystemServlet extends HttpServlet {
      @EJB
      private MemberManagerRemote mm;
  
      private String success=null;
  
      public void init(){
          System.out.println("LibrarySystemServlet: init()");
      }
  
      protected void processRequest(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          System.out.println("LibrarySystemServlet: processRequest()");
          try {
              RequestDispatcher dispatcher;
              ServletContext servletContext=getServletContext();
  
              String page=request.getPathInfo();
              page=page.substring(1);
  
              if("CheckLogIn".equals(page)){
                  success=logIn(request);
                  request.setAttribute("data", success);
              }
              else{
                  page="Error";
              }
              dispatcher=servletContext.getNamedDispatcher(page);
              if(dispatcher==null){
                 dispatcher=servletContext.getNamedDispatcher("Error");
              }
              dispatcher.forward(request, response);
          } catch(Exception ex) {
              log("Exception in LibraySystemServlet.processRequest()");
          }
      } 
  
      private String logIn(HttpServletRequest request){
          String s;
          String memberId=request.getParameter("memId");
          String pw=request.getParameter("pw");
          if(pw.equals(mm.getMemberPw(memberId))){
              s="Success";
          }
          else{
              s="Failed";
          }
          return s;
      }
  
      @Override
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          System.out.println("LibrarySystemServlet: doGet()");
          processRequest(request, response);
      } 
  
      @Override
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
          System.out.print("LibrarySystemServlet: doPost()");
          processRequest(request, response);
      }
  
      public void destroy(){
          System.out.println("LibrarySystemServlet: destroy()");
      }
  }
  </code></pre>
  
  <p>web.xml</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app version="2.5" 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_2_5.xsd"&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;LibrarySystemServlet&lt;/servlet-name&gt;
          &lt;servlet-class&gt;servlets.LibrarySystemServlet&lt;/servlet-class&gt;
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;CheckLogIn&lt;/servlet-name&gt;
          &lt;jsp-file&gt;/CheckLogIn.jsp&lt;/jsp-file&gt;
      &lt;/servlet&gt;
      &lt;servlet&gt;
          &lt;servlet-name&gt;Error&lt;/servlet-name&gt;
          &lt;jsp-file&gt;/Error.jsp&lt;/jsp-file&gt;
      &lt;/servlet&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;CheckLogIn&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/CheckLogIn&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;Error&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/Error&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;LibrarySystemServlet&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/librarySystemServlet/*&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;welcome-file-list&gt;
          &lt;welcome-file&gt;LogIn.jsp&lt;/welcome-file&gt;
          &lt;/welcome-file-list&gt;
      &lt;/web-app&gt;
  </code></pre>
  
  <p>Any help would be greatly appreciated!</p>