processing checkboxes

Hello

I am fairly new to JSPs. I basically have a simple page in which i will have bunch of checkboxes. user can select some checkboxes and click delete. once delete button is called i am going to a back end java code. How, in my java code, can I get which checkboxes were selected? can I get all the checkboxes that were selected as an array or list or any type of collection?

thanks!

[404 byte] By [bhaarat_javaa] at [2007-11-27 8:12:50]
# 1

>can I get all the checkboxes that were selected as an array or list or any type of collection?

Yes you can.

Give all the checkboxes the same name, with their value being the "id" of the thing you want to delete.

<input type="checkbox" name="deleteUser" value="42">

<input type="checkbox" name="deleteUser" value="69">

<input type="checkbox" name="deleteUser" value="666">

At the server end after you submit this form:

String[] idsToDelete = request.getParameterValues("deleteUser");

This String[] will have only the values of the checkboxes you have selected. It it then relatively simple to iterate through the array and call delete for each one.

Cheers,

evnafets

evnafetsa at 2007-7-12 19:57:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
thank u so much! can you also please tell me some book where i'd be able to learn these kind of things? basically something that has jsp knowledge along with server side java code? thanks again!
bhaarat_javaa at 2007-7-12 19:57:16 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...