| | |
How to store Answer avilable in option format in table
Please support our JSP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2008
Posts: 38
Reputation:
Solved Threads: 0
Hi,
I have one jsp page containing 2o questions retrieved from table along with its possible four-option answer in this manner:
Question1:
Option-a
Option-b
Option-c
Optio-dAll the options are in radio button form. I am trying to store the result of these question test in my final output table:
So, How it is possible to store the result of all question with answer equals to one of the four options in the same row of questioned.
Here questioned is same for all questions:
Here is fillquestion.jsp page:
Thanks and Regards
Haresh
I have one jsp page containing 2o questions retrieved from table along with its possible four-option answer in this manner:
Question1:
Option-a
Option-b
Option-c
Optio-dAll the options are in radio button form. I am trying to store the result of these question test in my final output table:
•
•
•
•
Structure of this table is:
Eventide -> int(2)->data from another event table
Question id ->int(2) ->data from questionbank table
Serialno ->int(3) ->data from questionbank table
Answer -> varchar(2) -> value of the option selected from above question page>
Here questioned is same for all questions:
Here is fillquestion.jsp page:
JSP Syntax (Toggle Plain Text)
<%-- Document : fillquestion Created on : Jul 18, 2008, 10:07:43 AM Author : user1 --%> <%@page contentType="text/html" pageEncoding="UTF-8"%> <%@ page language ="java" %> <%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Fill-up-Question</title> </head> <body> <form name="fill-ok" action="fill-question-ok.jsp" method="POST"> <table width="50%" border="1" borderColor="#000066" cellspacing="0" cellpadding="5" align="center"> <TBODY> <tr> <td colspan="8" align="middle" class="StripColor"> <font class="FontGeneralBoldWhite">Fill Up the Question</font> </td> </tr> <% String ID=request.getParameter("id"); String EVENTID=request.getParameter("EventID"); Connection connection = null; Statement st = null; ResultSet rs = null; Class.forName("com.mysql.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123"); st=con.createStatement(); try { rs = st.executeQuery("SELECT * FROM questionbank where questionid='"+ID+"'"); while ( rs.next() ) { %> <tr> <input type="hidden" name="eventid" value="EVENTID" /> <td><%=rs.getString("qserialno")%>: <b>Question:</b> <%=rs.getString("questionname")%> </td> </tr> <tr> <td><input type="hidden" name="QserialNO" value="<%=request.getParameter("Qserialno")%>"></td> <td><b>A:</b><input type="radio" name="opa" value="A" /><%=rs.getString("OptionA")%></td> <td><B>B:</B><input type="radio" name="opb" value="B" /><%=rs.getString("OptionB")%></td> <td><B>C:</B><input type="radio" name="opc" value="C" /><%=rs.getString("OptionC")%></td> <td><B>D:</B><input type="radio" name="opd" value="D" /><%=rs.getString("OptionD")%></td> </tr> <% } } finally { if (rs != null) { rs.close(); rs = null; } if (st != null) { st.close(); st = null; } } %> </table> <tr> <TD> <input type="submit" value="SUBMIT" name="submit" /></TD> <td><input type="reset" value="RESET" name="reset" /></td> </tr> </form> </body> </html>
Thanks and Regards
Haresh
![]() |
Other Threads in the JSP Forum
- Previous Thread: Need to build JAva Web Application
- Next Thread: How to Call Servlet from JSP
| Thread Tools | Search this Thread |
apache array backbutton combobox comma connection csv database development directorystructure dropdownlist dynamicpagetitles eclipse frames glassfish ie8 imagetodatabse imageupload integer internet java javaee javascript jsf jsp jsppagetitles levels mvc2 mvcmodel2 mysql netbeans network parameters passing ping printinserverinsteadofclient read redirect request.getparameter response seperated servlet servletdopost()readxml sessions software sql ssl state_saving_method stocks sun tomcat tutorial update values video web write





