java...jsp....delete record

this is my code snippet which lists all the users from  a table...

<%@ page session="true" %>
<%@ page language="java" %>
<%@ page import="java.util.Vector" %>
<%@ page import="java.lang.Integer" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.TreeMap" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.*" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Welcome to Department of US Army - C4ISR</title>

<!-- Style Sheet -->

<link  href="stylesheet.css" type="text/css" media="all" rel="stylesheet" />

<style type="text/css">
<!--
.style4 {
      font-size: 16px;
      font-weight: bold;
}
-->
</style>
</head>

<%
response.setHeader("Cache-Control","no-store"); //HTTP 1.1
response.setHeader("Pragma","no-cache"); //HTTP 1.0
response.setDateHeader ("Expires", 0); //prevents caching at the proxy server
%>

<%
       System.out.println("Now entered adminMain.jsp");
       String req_count = (String)request.getAttribute("req_count")==null?"0":(String)request.getAttribute("req_count");
       String errMsg = "";
%>



<body>
<!-- Header logo-->
<table width="100%" border="0">
  <tr>
    <td width="8%" height="57" rowspan="3">&nbsp;</td>
    <td width="92%">&nbsp;      </td>
  </tr>
  <tr>
    <td height="10" style="font-family:arial;text-align:left;font-weight:bold;padding:3 0; margin-bottom:-1;"><span class="style4">Welcome to Department of US Army</span> </td>
  </tr>
  <tr>
    <td><img src="Images/ArmySeal.gif" /></td>
  </tr>
</table>

  <!-- Header logo ends here-->
<hr color="#D0B623" />
<table border="0" cellspacing="0" class="form-noindent">
  <tr>
    <td colspan="4" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td height="17" colspan="3" valign="top" class="color_D0B623">    </td>
    <td width="1073" rowspan="8" valign="top"><table width="100%" border="0" cellspacing="0">
      <tr>
        <td colspan="3">&nbsp;</td>
      </tr>
      <tr>
        <td width="2%" height="708">&nbsp;</td>
        <td width="96%" valign="top" class="headings"><p> List Of All Users </p>
          <p>
            
             <%
                  List searchMap = new ArrayList();
                  searchMap = (List)request.getAttribute("searchMap");
                  String tempData ="";
                  String tempData_Key = "";
                  
                  if(searchMap == null || searchMap.size() == 0){
                        String errmsg = "Currently are no Temporary Requests for C4iSR - Suspense Tracking System";
            %>
                  <h3 class="labeltxtb" align="center"><%out.write(errmsg);%></h3>
            <%}      else{ %>
                  <table border="1" bordercolor="#D0B623" align="center" width="589" cellpadding="0" cellspacing="0" title="This table shows the results of the search query">
                  <tr class="labeltxtb">
                  <!-- Here Depending on the Option selected the sequence will be changed-->
                        <th>#</th>
                        <th>C4ISR ID </th>
                        <th>FIRST NAME </th>
                        <th>LASTNAME</th>
                        <th>EMAIL</th>
                        <th>START DATE </th>
                        <th>END DATE </th>
                        <th>CREATED ON</th>
                        <th>TYPE</th>
                        <th>DO THIS</th>
                        
                    <% }%>
                  <%
                  
                  Iterator i = searchMap.iterator();
                  int j = 1;
      
                  
                  while(i.hasNext()){
                        Vector dataVector = (Vector)i.next();
                        if(dataVector !=null){
                        
                              int dataVectorSize = dataVector.size();
                              String id=dataVector.get(0).toString();
                              out.println("<tr>");
                        
                                    
                              out.println("<td class=\"labeltxt\" align=\"center\" >&nbsp;");
                              out.println(j);
                              out.println("&nbsp;</td>");
                              j++;
                              for(int vectorIndex=0;vectorIndex<dataVectorSize;vectorIndex++){
                                    tempData = dataVector.get(vectorIndex)==null ?"" :dataVector.get(vectorIndex).toString();
                                    
                                    if(vectorIndex==3)
                                          tempData_Key = tempData;
                                          
                                    out.println("<td class=\"labeltxt\" align=\"center\" >&nbsp;");
                                    out.println(tempData);
                                    out.println("&nbsp;</td>");
                                    
                                    
                              }// end of for loop
                              

                              out.println("<td class=\"labeltxt\" align=\"center\" >&nbsp;");
                              out.println("<a href=\"approveTempUser.jsp?username=" + tempData_Key + "\" target=\"_self\"><font color=\"red\">" + "Delete" + "</font></a>");
                              out.println("&nbsp;</td>");
                                    
                              
                        
                              out.println("</tr>");
                        
                        
                        }// end of if loop
                        else
                        out.println("Unable to retrieve the data properly. please contact system administrator");
                        
                        
                  }//end of while loop      
                              

                                          %>

                        
                  </table>
                  
              </td>
        <td width="2%">&nbsp;</td>
      </tr>
      <tr>
        <td height="16" colspan="3" valign="top">&nbsp;</td>
      </tr>
    </table>
      <p>&nbsp;</p>
    <p>&nbsp;</p></td>
  </tr>
  <tr>
    <td width="24" height="98" class="color_D0B623">&nbsp;</td>
    <td width="206" valign="top"><div id="navcontainer">
<ul id="navlist">
<li >
  <div align="center"><a href="#" >Add Suspense</a></div>
</li>
<li>
  <div align="center"><a href="#">Search Suspense</a></div>
</li>
<li>
  <div align="center"><a href="#">Generate Report</a></div>
</li>
<li>
  <div align="center"><a href="#">Change Profile</a></div>
</li>
</ul>
</div></td>
    <td width="24" height="98" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td height="18" colspan="3" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td width="24" height="98" class="color_D0B623">&nbsp;</td>
    <td width="206" valign="top"><div id="navcontainer">
<ul id="navlist">
<li >
  <div align="center"><a href="#" >Authentication Requests (<font color="#FF0000"><b> <% out.println(req_count);%></b></font> ) </a></div>
</li>
<li>
  <div align="center"><a href=ForwardToAddUser target="_self" >Add New User </a></div>
</li>
<li>
  <div align="center"><a href="#">Delete/Deactivate User </a></div>
</li>
<li>
  <div align="center"><a href="">View all Users </a></div>
</li>
</ul>
</div></td>
    <td width="24" height="98" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td height="17" colspan="3" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td width="24" height="71" class="color_D0B623">&nbsp;</td>
    <td width="206" valign="top"><div id="navcontainer">
<ul id="navlist">
<li >
  <div align="center"><a href=ForwardToAddChief target="_self" >Add Chief</a></div>
</li>
<li>
  <div align="center"><a href="#">Delete/Deactivate Chief</a></div>
</li>
<li>
  <div align="center"><a href="#">View all Chiefs </a></div>
</li>
</ul>
</div></td>
    <td width="24" height="71" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td height="17" colspan="3" class="color_D0B623">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="3"><p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p>
    <p>&nbsp;</p></td>
  </tr>
</table>
<table width="100%" border="0">
  <tr>
    <td><div class="footer" >
        <div align="center">©2006 US Army -      <a href="#">Terms of Use</a> - <a href="#">Privacy Policy</a> </div>
      </div>&nbsp;</td>
  </tr>
</table>
<p>&nbsp; </p>
</body>
</html>
...............................

at the end of each record...i'm having a link which says "Delete"..now when i click on this that particular record should be deleted  from database. and i need to do this using servlet.
how can i take a key to identify the record to the servlet when it is in the form of link.... i know the other way around is using .jsp?key value.....which is currently used in the code as you see.....but want that aspect to be removed and replaced with a servlet concept....

thankz
LVL 10
jagadeesh_motamarriAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jagadeesh_motamarriAuthor Commented:
sample table that gets displayed on jsp page....

# C4ISR ID  FIRST NAME  LASTNAME EMAIL START DATE  END DATE  CREATED ON TYPE DO THIS
  1     michael.kasprowicz     Michael     Kasprowicz     lkr3@njit.edu     Apr-1-2006     Apr-16-2006     Jul-8-2006 12:40:08 AM     Administrator     Delete  
  2     jags_jm337     Jagadeesh     Motamarri     jm337@njit.edu     Apr-1-2006     Apr-1-2007     Jul-8-2006 11:02:44 AM     Temporary User     Delete  
  3     kramagoni     Kiran     Kumar     lkr3@njit.edu     Apr-1-2006     Apr-1-2008     Jul-8-2006 11:05:51 AM     Administrator     Delete  
  4     steve.waugh     Steve     Waugh     lkr3@njit.edu     Mar-29-2008     Mar-27-2009     Mar-27-2006 05:50:27 PM     Temporary User     Delete  
  5     RichEgan     Rich     Egan     jagadeesh.motamarri@gmail.com     Mar-27-2006     Mar-27-2007     Mar-27-2006 06:38:39 PM     Temporary User     Delete  
  6     john.hughes     John     Hughes     lkr3@njit.edu     Mar-30-2006     Mar-30-2006     Jul-6-2006 03:56:52 PM     Temporary User     Delete  


0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
I think you can do this by using a hidden variable in the jsp. Just set this hidden variable value to the key value onClick of the Link using JavaScript and later in the servlet use request.getParameter of this hidden variable. tht will get you the key value based on which you can do the delete operation.

I think this will do if i have understood your question correctly.
:-)

Thank you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.