Adding a Link to Delete an Employee

In the following instructions, you add a link to each row of the employees table on the employees.jsp page. Clicking on that link will delete all employee data for that row.

  1. Open employees.jsp in the Visual Editor.
  2. In the 'Insert Employee' column you created to contain the Edit link (see Figure 5-7), add another link for deleting the row. To do this, double-click the scriptlet that is inside the Employees table, to display the Scriptlet Properties dialog box.
  3. Modify the scriptlet to include a link to a delete_action.jsp page. The modified scriptlet should contain the following code:
        while (rset.next ())
        {
        out.println("<tr>");
          out.println("<td>" + 
          rset.getString("first_name") + "</td><td> " + 
          rset.getString("last_name") + "</td><td> " + 
          rset.getString("email") + "</td><td> " + 
          rset.getString("job_id") + "</td><td>" + 
          rset.getString("phone_number") + "</td><td>" + 
          rset.getDouble("salary") + 
          "</td><td> <a href=\"edit.jsp?empid=" + rset.getInt(1) +
          "\">Edit</a>   <a href=\"delete_action.jsp?empid=" + 
          rset.getInt(1) + "\">Delete</a></td>");
        out.println("<tr>");
        }
    
  4. Save employees.jsp.