Hi everybody,
I am going to develop a web application by using jsp, in this application when I retrieve multiple rows from table into form as following :

<%Vector v1,v2;
jmm.Database database = new jmm.Database(pageContext.getServletContext().getRealPath("/WEB-INF/config.txt"));
database.jdbcConnect();
String sql;



sql = "select question_text from tableA where type = 'Student'' ";

 v1=database.jdbcMultipleRowQuery(sql);
	for(int i=0;i<v1.size();i++){
	v2 = (Vector)v1.elementAt(i);
for(int j=0;j<v2.size();j++){

%>
<input type="hidden" name="q" value="<%out.print(""+v2.get(j)+"");%>" size="1">
<b><font color="#000000" size="3" > <p align="left"> <%out.print(i+1);%>)<%out.print(""+v2.get(j)+"");%> </font></b></p>
				
</p>
<table border="0" width="100%">
<tbody><tr>
<td align="left" width="16%">
<p align="left"><font size="2"><b>Very satisfied</b></font></td>
<td align="center" width="16%">
<p align="left"><font size="2"><b>Satisfied</b></font></td>
<td align="center" width="16%">
<p align="left"><font size="2"><b>Neither</b></font></td>
<td align="center" width="16%">
<p align="left"><font size="2"><b>Dissatisfied</b></font></td>
<td align="center" width="16%">
<p align="left"><font size="2"><b>Very dissatisfied</b></font></td>
</tr>
<tr>
<td align="left">
<p align="left"><font size="2"><b>
<input name="o" value="1" type="radio">1.</b></font></td> 
<td align="center">
<p align="left"><font size="2"><b><input name="o" value="2" type="radio">2.</b></font></td> 
<td align="center">
<p align="left"><font size="2"><b><input name="o" value="3" type="radio">3.</b></font></td> 
<td align="center">
<p align="left"><font size="2"><b><input name="o" value="4" type="radio">4.</b></font></td> 
<td align="center">
<p align="left"><font size="2"><b><input name="o" value="5" type="radio">5.</b></font></td> 
</tr>
</tbody></table>

				<p align="center" style="text-align: center">

<%
}
}
database.jdbcConClose();
database = null;
%>

And I want to insert all rows of this query into another table , actually I ‘ve written the following code

<%
String q=request.getParameter("q");
String o=request.getParameter("o");

jmm.Database database = new jmm.Database(pageContext.getServletContext().getRealPath("/WEB-INF/config.txt"));
database.jdbcConnect();
String sql;


sql = "INSERT INTO tableB  (answer,username, question_text) VALUES ('"+o+"','"+user+"','"+q+"')";
database.jdbcInsert(sql);

	
out.print("inserted successfully");
database.jdbcConClose();
database = null;
%>

This worked, but it just insert the data of first row while I want to insert all of them.
Thank you in advanced

I'm sorry to say, but you have no idea of basic Java-database communication. For general info on Java web application and database communication have look at this example and you should read Head First Servlets & JSP

I'm sorry to say, but you have no idea of basic Java-database communication. For general info on Java web application and database communication have look at this example and you should read Head First Servlets & JSP

sir , a i use jsp but i do not follow MVC structure (no javabeans, no servlet classes ) every thing inside the jsp file as you see in my code .
so it seems stupid question but i stuck here . so can you just show me how can i do it ? because as i said i dont follow MVC

thanks
it has been solved

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.