my dog learned polymorphism*
The moose likes JSP and the fly likes delete records Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "delete records" Watch "delete records" New topic

delete records

jyotsana dang
Ranch Hand

Joined: Sep 26, 2003
Posts: 135
i have a link to the deletion page in whcih the first 5 records that have been stored by the user are shown..and a checkbox besides each..
on checking the box/ boxes and on clicking the delete button the records get deleted..
how do we implement this thing with JSP.
Praful Thakare
Ranch Hand

Joined: Feb 10, 2001
Posts: 613
Check out if follwing example helps you,

here I go......
give same name to all your checkbox and value as primary key of record to be deleted...
say I have an record identified by rollno ,so while displaying record I will use following code...
....//select statement and all...
out.pritnln("<tr><td><input type=checkbox name=deletedRec value="+rs.getString("rollno")+........."</td></tr> ) ;


so In your example you will get 5 check box,all with name deleteRec.but different values...
now when you click on delete button,all selected check boxs value will be added to request,which can be collected as
String ids[]=request.getParameterValeus("deleteRec");

now using this string array you can construct query as
delete from soNso where rollno in(ids from array);
Hope this helps
[ March 01, 2004: Message edited by: Praful Thakare ]

All desirable things in life are either illegal, banned, expensive or married to someone else !!!
I agree. Here's the link:
subject: delete records
Similar Threads
How to link different buttons to different action methods
Database Record or User Record?
how to delete huge amount of records
How to get checkboxes from request parameter