title: Give a javascript alert after submit JSP without refreshing the page
body: <p>I am entering data into a jsp page and validating it from the database. I need to give an alert on the JSP page if the validation is false without refreshing the page as the user is forced to re-enter all the details when the page is refreshed:
  My validation Method:</p>
  
  <pre><code>public boolean accountCifMismatch(String account, String custid) {
          Connection conn;
          int count = 0;
          try {
              conn = db.getDbConnection();
              String sql = pr.getDBProperty().getProperty("com.crb.accountCifMismtach");
              PreparedStatement ps = conn.prepareStatement(sql);
              ps.setString(1, account);
              ps.setString(2, custid);
              ResultSet rs = ps.executeQuery();
              while (rs.next()) {
                  count = rs.getInt(1);
              }
              DBConnection.closeConn(conn);
              System.out.println(MemoryListener.getMemoryDetails());
          } catch (Exception asd) {
              System.out.println(asd.getMessage());
              return false;
          }
          return count == 0;
      }
  </code></pre>
  
  <p>My servlet call:</p>
  
  <pre><code>Fraud fmd = new Fraud();
   if (!fmd.accountCifMismatch(account_no, cust_id)) {
  //Continue Processing
  } else {
            session.setAttribute("accountcifmismtach", true);
            session.setAttribute("content_page", "fraud.jsp");
               }
  </code></pre>
  
  <p>and on <code>fraud.jsp</code> I call a javascript:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
      if (${accountcifmismtach == 'true'}) {
          alert("Account Number CIF Mismtach");
      }
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>EDIT</strong> I am submitting the form:</p>
  
  <pre><code> &lt;form id="form1" name="form1" method="post" action="do?MOD=BOK&amp;ACT=doFindFraud"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>The alert shows and then the page is refreshed, so the user has to input all the details once more. How can I show the alert without refreshing the page?</p>