Delete Record using HTML Hyperlink JSP!!!

Hello Guys!!!

I want to delete the record from MS Access DB by using HTML Hyperlink. I have HTML Table that i used to display the contents of DB. DB contains about five records and HTML Table also displays the delete Hyperlink against each record. Now i want that Hyperlink to delete particular record from DB when clicked. I tried to accomplish this by using servlets but i don't understand how to do it. Anybody knows how can i do this? Any help is appreciated..... Thanks!!!

this code delete the record by asc order from database and also from html table but problem is if i click on delete hyperlink of 4th record in html table it delete the first record. I want to delete the 4th record instead of 1st record. How to delete record of selected row from html table and as well as database? how to reference html table row or table cell value in servlet?

Re: Delete Record using HTML Hyperlink JSP!!!

How is the servlet supposed to know which student to delete?
You have not sent any information in that link to tell the servlet what to delete.
I would expect a parameter, eg 'id=1', representing the ID of the record to delete.

Re: Delete Record using HTML Hyperlink JSP!!!

No this servlet code delete the record in desc order in html table......first sql statement select the id of students in desc order and put the results in result set and next sql statement delete the records in desc order but that's not what i want.....how to get html table cell value without using javascript? because i don't wanna use javascript. if i able to get values of ID then its easy for me to delete record of selected row........help me plz!!!

Re: Delete Record using HTML Hyperlink JSP!!!

I've told you.
You need to add the id to the URL.
The Update will be a bit more problematic, but you could put multiple forms on the page I suppose, since you appear to be opposed ot using Javascript (which would be the proper solution).

Re: Delete Record using HTML Hyperlink JSP!!!

Originally Posted by hassaanid2012

No this servlet code delete the record in desc order in html table......first sql statement select the id of students in desc order and put the results in result set and next sql statement delete the records in desc order but that's not what i want.....how to get html table cell value without using javascript? because i don't wanna use javascript. if i able to get values of ID then its easy for me to delete record of selected row........help me plz!!!

try geting the id from database record using the rs.get method in the url link to the same page ie <a href delete.jsp? id=<%=rs.getString%>
then on the same page write the following code
int id = request.getparameter("id");
then write your sql query for delete