I have a JSP page that displays rows of user/password with a check box in front of each user. The administrator will use this to delete users from the DB. How would I set up the Servlet to iterate through the list of checked users and delete them from the DB? [ September 21, 2006: Message edited by: Bear Bibeault ]
I use a bean, so this may be different from what you are looking for but maybe it will help. I have an inner class in my bean which takes a string, and then has a Delete FROM XyourtableX WHERE XnameofvalueqeuriedX = "?". the XyourtableX should be the name of your table, and the XnameofvaluequeriedX should be the value you are using to find the enrty to delete. I use the primary key, as there can only be one and you will not delete multiple entries that way. The JSP which processes the removal of the checked items should retrieve the values of the checked boxes, probably by using request.getParameter(), where you have some variable equal it and name that whatever you want to pass to the bean. BTW, there was a great example of what you are trying to do with Begenning JSP Web Services Programming by Wrox. They have an example like what you are trying to do. I think you can download the sample code from their website.
In my databases, I never actually "delete" anything. Why? Because you never know when you want to go back and get data, especially something small like a user list. Therefore, I would created your database with a "deleted" column which you them check when the user deletes themselsves. Then, all your queries against the database should obviously ignore the deleted users, unless you are doing some historical analysis of old users.