title: save data through jsp into access file
body: <p>errors are..
  null pointer exception 
  and it didnot save data and error repeate two times </p>
  
  <pre><code>     &lt;%@page import="java.sql.*" %&gt;
       &lt;%@page import="java.sql.DriverManager"%&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=iso-8859-1" /&gt;
        &lt;title&gt;addProduct&lt;/title&gt;
  
  
     &lt;body&gt;
        &lt;table width="750" height="800" border="3" align="center" bordercolor="#55A0FF"&gt;
     &lt;tr&gt;
      &lt;td width="147" height="151" bgcolor="#000000"&gt;&lt;img src="PCMS.png" width="145"
      height="133" hspace="0" vspace="0" align="baseline" /&gt;&lt;/td&gt;
    &lt;td width="584" height="140" bgcolor="#8DC7C7" class="style1"&gt;&lt;div    
     align="center"&gt;Product Catalogue Management System(PCMS) &lt;/div&gt;&lt;/td&gt;
     &lt;/tr&gt;
     &lt;tr&gt;
     &lt;td height="567" valign="top" bgcolor="#B4CC8E"&gt;&lt;p&gt;&lt;a       
     href="manageProduct.jsp"&gt;Home&lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="viewProduct.jsp"&gt;View Products &lt;/a&gt;&lt;/p&gt;
    &lt;p&gt;&lt;a href="addProduct.jsp"&gt;Add Product &lt;/a&gt;&lt;/p&gt;
     &lt;p&gt;&lt;a href="deleteProduct.jsp"&gt;delete Product&lt;/a&gt;&lt;/p&gt;&lt;/td&gt;
     &lt;td valign="top" bgcolor="#D6D6D6"&gt;&lt;p align="center"&gt;&lt;br /&gt;
    &lt;strong&gt;Add New Product:  &lt;/strong&gt;&lt;/p&gt;
    &lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
    &lt;form id="addform" name="addform" method="post" action="saveDisplay.jsp"&gt;
  
      &lt;table width="394" height="392" border="1" align="center" cellspacing="0"  
       bordercolor="#999999"&gt;
      &lt;tr&gt;
        &lt;td width="107" align="left"&gt;Product ID:&lt;/td&gt;
        &lt;td width="223" align="left"&gt;&lt;input name="txtPID" type="text" id="txtPID" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;tr&gt;
        &lt;td width="107" align="left"&gt;Product Name:&lt;/td&gt;
        &lt;td width="223" align="left"&gt;&lt;input name="txtPName" type="text" id="txtPName" 
        /&gt;&lt;/td&gt;
       &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td align="left"&gt;Product Category: &lt;/td&gt;
        &lt;td align="left"&gt;&lt;select name="select"&gt;
          &lt;option selected="selected"&gt;Select Category&lt;/option&gt;
          &lt;option&gt;Course materials&lt;/option&gt;
          &lt;option&gt;T- Shirts&lt;/option&gt;
          &lt;option&gt;USB&lt;/option&gt;
                            &lt;/select&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td align="left"&gt;Price&lt;/td&gt;
        &lt;td align="left"&gt;&lt;input name="txtPPrice" type="text" id="txtPPrice" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td align="left"&gt;Currently available::&lt;/td&gt;
        &lt;td align="left"&gt;&lt;label&gt;
          &lt;input name="radiobutton" type="radio" value="Yes" /&gt;
          In stock 
          &lt;input name="radiobutton" type="radio" value="No" /&gt;
          Not in Stock 
        &lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td align="left"&gt;Quantity&lt;/td&gt;
        &lt;td align="left"&gt;&lt;input name="txtPQty" type="text" id="txtPQty" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
        &lt;td align="left"&gt;Description&lt;/td&gt;
        &lt;td align="left"&gt;&lt;textarea name="txtPDescription" id="txtPDescription"&gt;
         &lt;/textarea&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;%   
      try
      {
          //Step 2: Load driver
          Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  
          //Step 3: Define the connection URL
          String url = "jdbc:odbc:productDSN";
  
          //Step 4: Establish the connection
          Connection con = null;
          con = DriverManager.getConnection(url, "", "");
  
          //Step 5: Create the statement
          Statement st = con.createStatement();
  
          //Step 6: Execute the query
          String sql = "SELECT * FROM product";
          PreparedStatement pStmt = con.prepareStatement(sql, 
          ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE);
  
          ResultSet rs = pStmt.executeQuery();
  
  
  
  
  
      String pName = request.getParameter("txtPName");
      String pCat = request.getParameter("select");
          String pPrice = request.getParameter("txtPPrice");
          String inStock = request.getParameter("radiobutton");
          String pQty = request.getParameter("txtPQty");
          String pDesc = request.getParameter("txtPDescription");
  
  
         if(inStock.equals("Yes"))
          {
      inStock="Yes";  
  
  
          }
          else
          {
  
      inStock="No";
  
          }
  
  
  
  
          rs.last();
          rs.moveToInsertRow();
  
  
          rs.updateString(2, pName);
          rs.updateString(3, pCat);
          rs.updateString(4, pPrice);
          rs.updateString(5, inStock);            
          rs.updateString(6, pQty);
      rs.updateString(7, pDesc);
  
  
  
      rs.insertRow();
  
          con.close();
          out.close();
  
      }catch(Exception ex)
      {
          System.out.println(ex);
      }
  
  
          %&gt;
      &lt;tr&gt;
        &lt;td align="left"&gt;&amp;nbsp;&lt;/td&gt;
        &lt;td align="left"&gt;&lt;label&gt;
          &lt;input type="submit" name="Submit" value="Submit" /&gt;
          &lt;input type="Reset" name="Reset" value="Reset" /&gt;
        &lt;/label&gt;&lt;/td&gt;
      &lt;/tr&gt;
     &lt;/table&gt;
      &lt;/form&gt;
      &lt;/td&gt;
     &lt;/tr&gt;
  
  
  
     &lt;/table&gt;
      &lt;/body&gt;
      &lt;/html&gt;
  </code></pre>
  
  <p>All complete code of page ..which recive data and save it into access file ..where ID field is autonumber and remaing are in text format in access file. it run two time when i click submit. Please help</p>