wood burning stoves*
The moose likes Servlets and the fly likes Inserting multiple checkbox values into a table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "Inserting multiple checkbox values into a table" Watch "Inserting multiple checkbox values into a table" New topic
Author

Inserting multiple checkbox values into a table

jaya-shree
Greenhorn

Joined: Mar 30, 2001
Posts: 8
I am working on a JSP Page which is required to insert record into two tables simultaneously.This page allows the user to add a grp and grant access rights to applications for that particular grp code.
This page also has checkboxes for each application that i am listing on the page. How do i write an insert query which allows me to insert the names of those applications into the table which are checked and also the group code.There are two tables and both the tables are linked using the group code.
k b
Greenhorn

Joined: Feb 01, 2001
Posts: 22
You can do like this:--
Let 1st Jsp ( having grp code and applications) do a submit to another Jsp say controller.jsp.

<form name="1stjsp" action="controller.jsp" method="POST">
In controller.jsp
You can retrieve those parameters using
request.getParameter(), request.getParameterNames() ( This is helpful when we have checkboxes and depends how you have coded the names for them).
Then do JDBC connection and write/insert into tables.
Finally when you are done we can forward back to the 1st page or another page using jsp forward tag.
<jsp:forward page="someother.jsp" />
Hope this helps.


Raja Shekhar
Ranch Hand

Joined: Apr 02, 2001
Posts: 49
hi J-Shree
just try this...
Store the name of the group in the Value atrribute of the
Check Box..

and Check whether check box is Checked /not..
if (check != null)
then just insert...
and let me know it works..

Raj
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Inserting multiple checkbox values into a table