In the below code I wish to ask the user to select at least 1 of the check boxes and then take that input along with the entered product_id and insert them into two different tables. so the problem am having is with passing multiple component_id's from the view/jsp page and the query statement in the servlet
<%
List<Component> components = new ArrayList<Component>();
components = ComponentDb.selectComponents();
for (Component component : components) {
%>
<tr>
<td></td>
<td><input type="checkbox" name="component_id" value="
<%=component.getId()%>" required="required"><%=component.getName()%></td>
//here i have the end of form and stuff i doubt its necessary
and my servlet is(as far as this is concerned)
String query = "insert into Product
(product_id,product_name,product_description,product_price) VALUES
('"+product_id+"','"+product_name+"','"+product_description+"','"+product_price+"');"+
"insert into PC(product_id,component_id) VALUES
("+product_id+","+component_id+")";
//kinda puzzled here on how to pass the values seperately
try {
ps = connection.prepareStatement(query);
int a = ps.executeUpdate(query);
Thank you