title: request.getPArameter() returning null
body: <p>I am trying to read the input by the user as soon as he clicks on a button. But unfortunately the <code>request.getParamater()</code> is always returning a <code>null</code> value. Can someone please help me I have been hours Trying to sort this out :(</p>
  
  <pre><code>&lt;%@ page import="java.io.*,java.util.*,java.sql.*"%&gt;
  &lt;%@ page import="javax.servlet.http.*,javax.servlet.*" %&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
  &lt;%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%&gt;
  
  &lt;html&gt; 
  &lt;head&gt;
  
      &lt;script language="javascript"&gt;
  
  
  
          function add()
          {
          &lt;%
      Integer quantity = 500;
      Integer code = 1000;
  
      //String codes = request.getParameter("code");
      String codes = (String) request.getParameter("code");
      String quanti = (String) request.getParameter("quantity");
  
      if (codes != null &amp;&amp; quanti != null) {
          quantity = Integer.parseInt(quanti);
          code = Integer.parseInt(codes);
      }
  
      out.println(code);
      out.println(quantity);
  
      String connectionURL = "jdbc:mysql://localhost:3306/products";
  
      Connection connection = null;
  
      PreparedStatement pstatement = null;
  
      Class.forName("com.mysql.jdbc.Driver").newInstance();
      int updateQuery = 0;
  
      // check if the text box is empty
      if (code != null &amp;&amp; quantity != null) {
          // check if the text box having only blank spaces
          if (codes != "" &amp;&amp; quanti != "") {
              try {
                  /* Create a connection by using getConnection()
                   method that takes parameters of string type 
                   connection url, user name and password to connect 
                   to database. */
                  connection = DriverManager.getConnection(connectionURL, "root", "170293m");
                  // sql query to insert values in the secified table.
                  String queryString = "INSERT INTO sales (code, quantity, price, name) VALUES (?, ?, ?, ?)";
                  /* createStatement() is used for create statement
                   object that is used for 
                   sending sql statements to the specified database. */
                  pstatement = connection.prepareStatement(queryString);
                  pstatement.setInt(1, code);
                  pstatement.setInt(2, quantity);
                  pstatement.setDouble(3, 50);
                  pstatement.setString(4, "aw ras");
                  updateQuery = pstatement.executeUpdate();
                  if (updateQuery != 0) {
                      out.println("Error in query");
                  }
              } catch (Exception ex) {
                  out.println("Unable to connect to batabase.");
  
              } finally {
                  // close all the connections.
                  pstatement.close();
                  connection.close();
          }
          }
      }%&gt;
              print();
          }
  
          function remove()
          {
  
          }
      &lt;/script&gt;
      &lt;title&gt;BestWholesaler LTd.&lt;/title&gt;
  &lt;/head&gt; 
  &lt;body&gt;
      &lt;h1&gt;Welcome to BestWholesaler Ltd. Online Ordering&lt;/h1&gt;
      &lt;h2&gt;Items Currently in Stock&lt;/h2&gt;
  
      &lt;sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
                         url="jdbc:mysql://localhost:3306/products"
                         user="root"  password="170293m"/&gt;
  
      &lt;sql:query dataSource="${snapshot}" var="result"&gt;
          SELECT Name, Code, PricePU, Quantity from productinfo;
      &lt;/sql:query&gt;
  
      &lt;table border="1" width="100%"&gt;
          &lt;tr&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Code&lt;/th&gt;
          &lt;th&gt;Price/Unit&lt;/th&gt;
          &lt;th&gt;Quantity Available&lt;/th&gt;
      &lt;/tr&gt;
      &lt;c:forEach var="row" items="${result.rows}"&gt;
          &lt;tr&gt;
          &lt;td&gt;&lt;c:out value="${row.Name}"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${row.Code}"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${row.PricePU}"/&gt;&lt;/td&gt;
          &lt;td&gt;&lt;c:out value="${row.Quantity}"/&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/c:forEach&gt;
  &lt;/table&gt;
  
  &lt;br&gt;
  &lt;br&gt;
  Enter Code:     &lt;input type="text" name="code" id="code" value="" /&gt;
  &lt;br&gt;
  Enter Quantity: &lt;input type="text" name="quantity" id="quantity" value="" /&gt;
  &lt;input type="button" value="ADD" name="add" onclick="add()" /&gt;
  &lt;input type="button" value="REMOVE" name="remove" onclick="remove()" /&gt;
  
  &lt;/body&gt;
  
  &lt;/html&gt;
  </code></pre>