title: In my jsp page I am trying to insert values to database but I dont see any error, page refreshes and the data is not inserted
body: <pre><code>Here is my code.
  &lt;%-- 
      Document   : index
      Created on : Jan 16, 2016, 2:49:24 PM
      Author     : Manoj
  --%&gt;
  &lt;%@page import="java.sql.*"%&gt;
  &lt;% Class.forName("org.apache.derby.jdbc.ClientDriver"); %&gt;
  &lt;%@page contentType="text/html" pageEncoding="UTF-8"%&gt;
  &lt;!DOCTYPE html&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
          &lt;title&gt;Inserting Data&lt;/title&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;h1&gt;Inserting Data&lt;/h1&gt;
          &lt;%!
              public class Contact {
                  String URL = "jdbc:derby://localhost:1527/contact";
                  String USERNAME = "nbuser";
                  String PASSWORD = "nbuser";
  
                  Connection conn = null;
                  PreparedStatement pst = null;
                  Statement stm = null;
                  ResultSet rst = null;
  
              public Contact(){
                  try{
                      conn = DriverManager.getConnection(URL, USERNAME, PASSWORD);
                      pst = conn.prepareStatement(
                      "INSERT INTO contactinfo (name, address, mobile)"+" VALUES (?, ?, ?)");
                      }
                  catch(SQLException e)
                  {
                      e.printStackTrace();
                  }
              }
              public int setContact(String name, String address, String mobile)
              {
                   int result =0;
                   try{
                      pst.setString(1, name);
                      pst.setString(2, address);
                      pst.setString(3, mobile);
  
                      result = pst.executeUpdate();
                   }
                   catch(SQLException e)
                   {
                      e.printStackTrace();
                   }
                   return result;
              }
              }
              %&gt;
              &lt;%
                 int result = 0;
                 if(request.getParameter("submit") != null){
                 String name = new String();
                 String address = new String();
                 String mobile = new String();
  
                 if (request.getParameter("name")!= null)
                 {
                     name = request.getParameter("name");
                 }
                   if (request.getParameter("address")!= null)
                 {
                     address = request.getParameter("address");
                 }
                     if (request.getParameter("mobile")!= null)
                 {
                     mobile = request.getParameter("mobile");
                 }
  
                 Contact contact = new Contact();
                 result = contact.setContact(name, address, mobile); 
                 }
              %&gt;
          &lt;form name="myform" action="index.jsp" method="POST"&gt;
              &lt;table border="0"&gt;
                 &lt;tbody&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Name&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="name" value="" size="30" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                      &lt;tr&gt;
                          &lt;td&gt;Address&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="address" value="" size="50" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;   
                       &lt;tr&gt;
                          &lt;td&gt;Mobile&lt;/td&gt;
                          &lt;td&gt;&lt;input type="text" name="mobile" value="" size="10" /&gt;&lt;/td&gt;
                      &lt;/tr&gt;
                  &lt;/tbody&gt;
              &lt;/table&gt;
              &lt;input type="reset" value="Clear" name="clear" /&gt;
              &lt;input type="submit" value="Submit" name="submit" /&gt;
          &lt;/form&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Kindly help me. This is the first time I am writing a JSP code.
  The database I am using is Apache derby within Neatbeans 8.1. I tried all alternatives but could not find a solution. When I manually insert a row into the database it is inserting the values. </p>