943,733 Members | Top Members by Rank

Ad:
  • JSP Discussion Thread
  • Unsolved
  • Views: 1132
  • JSP RSS
Jul 22nd, 2008
-1

How to store Answer avilable in option format in table

Expand Post »
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-d
All the options are in radio button form. I am trying to store the result of these question test in my final output table:
Quote ...
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>
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:

JSP Syntax (Toggle Plain Text)
  1. <%--
  2. Document : fillquestion
  3. Created on : Jul 18, 2008, 10:07:43 AM
  4. Author : user1
  5. --%>
  6.  
  7. <%@page contentType="text/html" pageEncoding="UTF-8"%>
  8. <%@ page language ="java" %>
  9. <%@ page import="java.sql.*, javax.sql.*, javax.naming.*,java.io.*,java.util.*" %>
  10. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  11. "http://www.w3.org/TR/html4/loose.dtd">
  12.  
  13. <html>
  14. <head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  16. <title>Fill-up-Question</title>
  17. </head>
  18. <body>
  19. <form name="fill-ok" action="fill-question-ok.jsp" method="POST">
  20.  
  21. <table width="50%" border="1" borderColor="#000066" cellspacing="0" cellpadding="5" align="center">
  22. <TBODY>
  23. <tr>
  24. <td colspan="8" align="middle" class="StripColor">
  25. <font class="FontGeneralBoldWhite">Fill Up the Question</font>
  26.  
  27. </td>
  28. </tr>
  29.  
  30. <%
  31. String ID=request.getParameter("id");
  32. String EVENTID=request.getParameter("EventID");
  33. Connection connection = null;
  34. Statement st = null;
  35. ResultSet rs = null;
  36. Class.forName("com.mysql.jdbc.Driver");
  37. Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/mynewdatabase","root", "root123");
  38. st=con.createStatement();
  39. try {
  40. rs = st.executeQuery("SELECT * FROM questionbank where questionid='"+ID+"'");
  41.  
  42. while ( rs.next() )
  43. {
  44. %>
  45. <tr>
  46. <input type="hidden" name="eventid" value="EVENTID" />
  47.  
  48. <td><%=rs.getString("qserialno")%>:&nbsp;&nbsp;<b>Question:</b>
  49. <%=rs.getString("questionname")%>
  50. </td>
  51. </tr>
  52. <tr>
  53. <td><input type="hidden" name="QserialNO" value="<%=request.getParameter("Qserialno")%>"></td>
  54. <td><b>A:</b><input type="radio" name="opa" value="A" /><%=rs.getString("OptionA")%></td>
  55. <td><B>B:</B><input type="radio" name="opb" value="B" /><%=rs.getString("OptionB")%></td>
  56. <td><B>C:</B><input type="radio" name="opc" value="C" /><%=rs.getString("OptionC")%></td>
  57. <td><B>D:</B><input type="radio" name="opd" value="D" /><%=rs.getString("OptionD")%></td>
  58. </tr>
  59. <%
  60. }
  61.  
  62. } finally
  63. {
  64. if (rs != null)
  65. {
  66. rs.close();
  67. rs = null;
  68. }
  69. if (st != null)
  70. {
  71. st.close();
  72. st = null;
  73. }
  74.  
  75. }
  76.  
  77. %>
  78. </table>
  79. <tr>
  80. <TD>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="submit" value="SUBMIT" name="submit" /></TD>
  81. <td><input type="reset" value="RESET" name="reset" /></td>
  82.  
  83. </tr>
  84. </form>
  85. </body>
  86. </html>


Thanks and Regards
Haresh
Reputation Points: 8
Solved Threads: 0
Light Poster
guravharsha is offline Offline
42 posts
since Jun 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JSP Forum Timeline: Need to build JAva Web Application
Next Thread in JSP Forum Timeline: How to Call Servlet from JSP





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC