title: JSP Data to Servlet using EL
body: <p>Good day!</p>
  
  <p>I am trying to delete a record. But before I delete it, i will show a confirmation message using JSP as follows: (ID and name from "Select ID" Servlet)</p>
  
  <pre><code>  &lt;form action = "Delete"&gt;    
    Id: ${student.id} &lt;br&gt;
    &lt;input type="submit" value="Delete"&gt;  
    &lt;/form&gt;
  </code></pre>
  
  <p>And my delete code is as follows:</p>
  
  <pre><code>public class Delete extends HttpServlet {
  
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
  
          response.setContentType("text/html;charset=UTF-8");
          PrintWriter out = response.getWriter();
          String query = "Delete FROM customer WHERE id = ?";
  
          try {
  
              Context context  = new InitialContext();
              DataSource ds = (DataSource) context.lookup("jdbc/myDatasource"); 
              Connection  con = ds.getConnection();
              PreparedStatement stmt = con.prepareStatement(query); 
              int id = Integer.parseInt(request.getParameter("id")); //ERROR HERE? 
              stmt.setInt(1, id);
              stmt.executeUpdate(query);
  
          } catch (Exception ex) {
              out.println("Error.... " + ex);
          }
  }
  </code></pre>
  
  <p>But I am having a <code>null pointer exeption</code>. It seems like the ID cannot be read. (But I am not sure). How can I pass data from JSP to Servlet using EL? What causes the error and how can I resolve it? Thank you.</p>