title: java.lang.NoSuchMethodException when submitting a form in Struts 2
body: <p>This is my code I had written a logic to fetch the <code>username</code> and <code>password</code> from and database and after login the login time and logout time should enter into the database the time should be taken from the system</p>
  <p><strong>action class:</strong></p>
  <pre><code>public class Login {
      private String username;
      private String password;
      private String login_time;
      private String logout_time;
      private String status;
      private String late;
      //getters and setters
  
   @SuppressWarnings(&quot;unused&quot;)
   public String execute(ServletRequest req) throws Exception,SQLException{
  int i=0;
      try{
          SessionUtils su = new SessionUtils(); 
          HttpSession session  =((Request) req).getSession();
          String hql=&quot;select * from login where username='&quot;+username+&quot;'and      
  password='&quot;+password+&quot;'&quot;;           
          
          Query query1=((SessionUtils) session).createQuery(hql);
          query1.setParameter(1,getUsername());
          query1.setParameter(2,getPassword());
          
          int result = query1.executeUpdate();
          while(i!=0)
          {
              RequestDispatcher rd 
   =req.getRequestDispatcher(&quot;DailyInOut.jsp&quot;);
              return  hql;
          }
           } catch (Exception e) 
           {
               return late;
           }
      return status;
     }
  
    public String chandu(ServletRequest req,ServletResponse res) throws      
    Exception,SQLException{
  int j=0;
  try
  {
      java.util.Date myDate = new java.util.Date();
      SimpleDateFormat formatter = new SimpleDateFormat(&quot;yyyy/MM/dd hh:mm:ss&quot;);
      String strDates1 = formatter.format(myDate);
      @SuppressWarnings(&quot;unused&quot;)
      SessionUtils su = new SessionUtils(); 
      String hql=&quot;update attendance  where date='&quot;+strDates1+&quot;' name='&quot;+username+&quot;' 
     login='&quot;+login_time+&quot;' logout='&quot;+logout_time+&quot;' status='&quot;+status+&quot;' 
   late='&quot;+late+&quot;'&quot;;
      
      HttpSession session  =((Request) req).getSession();
      Query query2=((SessionUtils) session).createQuery(hql);
      session.setAttribute(&quot;date&quot;, strDates1);
      session.setAttribute(&quot;login_time&quot;,login_time);
      session.setAttribute(&quot;logout_time&quot;,logout_time);
      session.setAttribute(&quot;status&quot;,status);
      session.setAttribute(&quot;late&quot;,late);
      @SuppressWarnings(&quot;unused&quot;)
      int result = query2.executeUpdate();
      System.out.println(&quot; update row updated&quot;);
      if(j!=0)
      {
      System.out.println(&quot;success1&quot;);
      return &quot;success&quot;;
  }
  }
  catch(Exception e)
  {
      e.getMessage();
  }
  System.out.println(&quot;failure page&quot;);
  return &quot;failure&quot;;
  }
  }
  </code></pre>
  <p><strong>struts.xml</strong></p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
  
  &lt;!DOCTYPE struts PUBLIC
      &quot;-//Apache Software Foundation//DTD Struts Configuration 2.1//EN&quot;
      &quot;http://struts.apache.org/dtds/struts-2.1.dtd&quot;&gt;
  
      &lt;struts&gt;
          &lt;package namespace=&quot;/&quot; name=&quot;packageOne&quot; extends=&quot;struts-default&quot;&gt;
              &lt;action name=&quot;login&quot; class=&quot;com.tribro.chandu.Login&quot; method=&quot;post&quot;&gt;
                  &lt;result name=&quot;success&quot;&gt;DailyInOut.jsp&lt;/result&gt;
                  &lt;/action&gt;
             &lt;/package&gt;
      &lt;/struts&gt;
  </code></pre>
  <p><strong>logina.jsp</strong></p>
  <pre><code>    &lt;html&gt;
     &lt;head&gt;
    &lt;title&gt;Home Page&lt;/title&gt;
    &lt;/head&gt;
    &lt;body bgcolor=&quot;cyan&quot; text=&quot;magenta&quot;&gt;
    &lt;form action=&quot;login&quot; method=&quot;execute&quot;&gt;
    &lt;img src=&quot;WebContent/Images/java.jpg&quot; height=&quot;80&quot;/&gt;
     &lt;pre&gt;&lt;marquee behavior=&quot;scroll&quot; direction=&quot;right&quot;&gt;&lt;font size=&quot;4&quot;&gt;Welcome to TRIBRO     
   Limited&lt;/font&gt;&lt;/marquee&gt;&lt;br/&gt;&lt;/pre&gt;
    &lt;table&gt;
    &lt;tr&gt;
    &lt;td&gt;
    &lt;div&gt;
    &lt;img src=&quot;WebContent/Images/banner.png&quot; height=&quot;300&quot; width=&quot;900&quot;&gt;&lt;/img&gt;
    &lt;/div&gt;
    &lt;/td&gt;
    &lt;td&gt;
    &lt;div&gt;
   &lt;table&gt;
   &lt;tr&gt;
   &lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;
   &lt;h4&gt;Login Form&lt;/h4&gt;
   &lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
   &lt;td&gt;
   &lt;h4&gt;Username :&lt;/h4&gt;
   &lt;/td&gt;
   &lt;td&gt;
   &lt;h4&gt;&lt;input type=&quot;text&quot; name=&quot;Username&quot;/&gt;&lt;/h4&gt;
    &lt;/td&gt;
   &lt;/tr&gt;
    &lt;tr&gt;
   &lt;td&gt;
   &lt;h4&gt;password:&lt;/h4&gt;
   &lt;/td&gt;
   &lt;td&gt;
   &lt;h4&gt;&lt;input type=&quot;password&quot; name=&quot;password&quot;/&gt;&lt;/h4&gt;
   &lt;/td&gt;
   &lt;/tr&gt;
   &lt;tr&gt;
    &lt;td colspan=&quot;2&quot; style=&quot;text-align:center;&quot;&gt;
   &lt;input type=&quot;submit&quot; value=&quot;Login&quot;/&gt;
   &lt;/td&gt;
   &lt;/tr&gt;
   &lt;/table&gt;
    &lt;/div&gt;
    &lt;/td&gt;
    &lt;/tr&gt;
   &lt;/table&gt;
   &lt;/form&gt;
   &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  <p>But I am getting an error as</p>
  <pre><code>java.lang.NoSuchMethodException: com.tribro.chandu.Login.post()
  </code></pre>