Help with result set
Below is part of a servlet i have made which get details out of a table, the problem is for each item in the table i have a button which i want to be able to use to delete the item from the table.
The way i am trying to do it is use an hidden form field so that when the button is clicked that items recording_id is passed to the servlet which deletes the data from the table.
My question is how do i get it to work correctly has right now the hidden field collects all the recording_id's instead of just the one for the item the user clicks.
// Create select statement and execute it
try{
// Build up the SQL statement from our data requirements
String selectSQL ="select recording_id, recording_title "+
"from wishlist "+
"where user_name = ' " + user +"'";
Statement stmt = conn.createStatement();
ResultSet rs1 = stmt.executeQuery(selectSQL);
System.out.println(selectSQL);
// output html headers
String title ="My WishList";
out.println(ServletUtilities.headWithTitle(title) +
"<BODY BGCOLOR=\"#a00e0e\">\n" +
"<center><img src=\"http://localhost:8080/examples/LOGO.jpg\" width=350 height=200/></center>\n" +
"<H1 ALIGN=\"CENTER\">" + title +"</H1>\n" +
"These are all the films you have added to your wish list, use this as a reminder of films you may wish to purchase or rent" );
// close the html
out.println("</BODY></HTML>");
out.println("<TABLE BORDER=1 ALIGN=\"CENTER\">\n" +
"<TR BGCOLOR=\"#FFAD00\">\n" +
" <TH>Item ID\n" +
" <TH>Title\n" +
" <TH> Remove from list \n" );
// Retrieve the results
while(rs1.next()){
String formURL =
"http://localhost:8080/examples/servlet/coreservlets.removewish";
formURL = response.encodeURL(formURL);
out.println("<FORM ACTION=\"" + formURL +"\">\n" +
"<INPUT TYPE=\"HIDDEN\" NAME=\"filmid\" " +
"VALUE=\"" + rs1.getString("recording_id") +"\">\n" +// THIS IS WHERE THE PROBLEM IS!!!!!!!!
"<INPUT TYPE=\"HIDDEN\" NAME=\"filmtitle\" " +
"VALUE=\"" + rs1.getString("recording_title") +"\">\n" +
"<TR>" +
"<TD>" + rs1.getString("recording_id") +"</TD>" +
"<TD>" + rs1.getString("recording_title") +"</TD>" +
"<TD>" +"<P>\n<CENTER>\n" +
"<INPUT TYPE=\"SUBMIT\" " +
"VALUE=\"Remove from Wishlist\">\n" +
"</CENTER>\n<P>\n</FORM>" +"</TD>\n");
System.out.println(rs1.getString("recording_id"));
}
// close the html
out.println("</TABLE></BODY></HTML>");
// Close the stament and database connection
//(must remember to always do this)
stmt.close();
conn.close();
}catch(SQLException se){
System.out.println(se);
}
}
}
}
Bascially i want it so when i press the button the recording_id for that film is also sent with it. Cany anybody help me?

