title: Updating mysql table with JSP and JavaScript
body: <p>I am a newbie in JSP. I am creating a table that shows the notification approval. 
  The function of it is to show whether the admin approves the record or not.
  However, when I click on the Accept button, nothing changed (both the page and the database remain 0). Is there any error in my code?? Please help. Thank you in advance.</p>
  
  <p>The Javascript in my JSP file:</p>
  
  <pre><code>&lt;script language="JavaScript"&gt;
  function submitaccept(){
      String connectionURL = "jdbc:mysql://localhost/ams";
      Connection connection =null;
      PreparedStatement pstatement = null;
      var sqlstr = "UPDATE notification SET ack_flag = 1 WHERE notification_id = 001;";
      connection = DriverManager.getConnection(connectionURL, "root", "");
      pstatement =connection.prepareStatement(sqlstr);
      pstatement.executeUpdate();
      location.reload(true);
  }
  </code></pre>
  
  <p>The call function of my JSP file:</p>
  
  <pre><code>    &lt;c:choose&gt;
          &lt;c:when test="${row.ack_flag=='0'}"&gt;
  
          &lt;a href="javascript:submitaccept()" &gt;
              Approve&lt;/a&gt; | 
  
          &lt;a href="notification.jsp" &gt; 
              Reject &lt;/a&gt;
          &lt;/c:when&gt;
  
          &lt;c:when test="${row.ack_flag=='1'}"&gt;
              Approved
          &lt;/c:when&gt;
          &lt;c:otherwise&gt;
              Rejected
          &lt;/c:otherwise&gt;
      &lt;/c:choose&gt;
  </code></pre>