File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JDBC and Relational Databases and the fly likes Trying to display checkbox checked values in new jsp page Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC and Relational Databases
Reply locked New topic

Trying to display checkbox checked values in new jsp page

gopi sri

Joined: Nov 11, 2008
Posts: 6
hello friends

i tried with servlet also. i created seperate file for database connections. still iam facing problem with insertion of checkbox values.

i can able to retrieve the values from database then i stored those values in checkbox. Now the checked values from checkbox should insert into db, here iam facing problem..First iam trying to display the checked values in out.println statement in new jsp page using request.getParameterValues("checkboxname"), but i cannot ablt to pass the values from first jsp page to second jsp page..
here is my code..first.jsp

<%@ page import="java.sql.*" %>
<%@ page import="*" %>

<title>display data from the table using jsp</title>
<h2 align="center"></h2>
<select id="cbosex" name="cbosex">
<option value="true">Male</option>
<option value="false">Female</option>

try {

Connection con = null;
Statement st= null;
ResultSet rs = null;
String s;

st = con.createStatement();
String sql="select seat_no from e_busticketing.seat_mast where bus_id=1001";

<TABLE cellpadding="15" border="1" style="background-color: #ffffcc;" width=20% align="center">
while (

<TD><INPUT TYPE=CHECKBOX NAME=c1 value='<%=s%>'><%=s%>

<% } %>



// close all the connections.

catch (Exception ex)

<font size="+3" color="red"></b>
out.println("Unable to connect to database.");

</TABLE><TABLE align="center">
<TD><FORM ACTION="second.jsp" method=get>

<input type="submit" value="submit">


<%! String[] se; %>
You have selected:

<% se = request.getParameterValues("c1");
if (se != null)
for (int i = 0; i < se.length; i++)
out.println ("<b>"+se[i]+"<b>");
} else
out.println ("<b>none<b>");%>

Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1082


Please do not post same problem again.

You have similar post in same forum, I think you solve your previous problem, you will be able to slove this as well. You have not even responded to that post to the people who tried to help you.

[ November 12, 2008: Message edited by: Shailesh Chandra ]

Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
I agree. Here's the link:
subject: Trying to display checkbox checked values in new jsp page
It's not a secret anymore!