Connecting Tech Pros Worldwide Forums | Help | Site Map

I hav a problem in my online exam code,pls help me

Newbie
 
Join Date: Jun 2009
Posts: 5
#1: Jun 15 '09
here is the code for my jsp
Expand|Select|Wrap|Line Numbers
  1. <%@ page import="java.sql.*,java.io.*,java.util.*" %>
  2. <%! 
  3.     Connection con = null;
  4.     PreparedStatement pst = null;
  5.     ResultSet rs=null;
  6.  
  7. %>
  8. <%
  9.    /* String driver = application.getInitParameter("driver");
  10.     String url = application.getInitParameter("url");
  11.     String user = application.getInitParameter("user");
  12.     String pwd = application.getInitParameter("pwd"); */
  13.  
  14.     Class.forName("oracle.jdbc.driver.OracleDriver");
  15.     con = DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:orcl","vak","exam");
  16.     pst=con.prepareStatement("select * from verbal ORDER BY dbms_random.value");
  17.     rs=pst.executeQuery();
  18.     %>
  19.  
  20. <html>
  21. <head>
  22. <title>VERBAL EXAM</title>
  23.  
  24. <style type="text/css">
  25. <!--
  26. .style7 {
  27.     font-size: 24px;
  28.     color: #330099;
  29.     font-weight: bold;
  30. }
  31. .style8 {
  32.     font-size: 18px;
  33.     color: #990000;
  34. }
  35. .style9 {font-size: 16px}
  36. -->
  37. </style>
  38. <script type="text/javascript">
  39. var c=0
  40. var t
  41. function abc()
  42. {
  43.  
  44.  window.location = "http://localhost:8083/onlineexam/numerical.jsp";
  45.  }
  46.  
  47. function timedCount()
  48. {
  49. document.getElementById('txt').value=c;
  50. if(c==10)
  51. abc();
  52. c=c+1;
  53. t=setTimeout("timedCount()",1000);
  54. }
  55. </script>
  56.  
  57. </head>
  58. <body onLoad="timedCount()">
  59. <form id="f1" name="form1" method="post" action="numerical.jsp" >
  60. <table width="975" height="362" border="0">
  61.   <tr>
  62.     <td width="10" height="218"><table width="741" border="0">
  63.       <tr>
  64.         <td width="237" height="212"><img src="images/logo.jpg" width="237" height="210" /></td>
  65.         <td width="231"><img src="images/bannerimg.jpg" width="752" height="210" /></td>
  66.       </tr>
  67.     </table></td>
  68.   </tr>
  69.   <tr bgcolor="#FFFFCA">
  70.     <td height="138"><div align="center" class="style7">
  71.       <p> </p>
  72.       <p>Verbal Ability </p>
  73.       <p align="right"><input type="text" id="txt" style="background-color:#FFFFCA"/></p>
  74.       <p align="left"><span class="style8">Sentence Completion Instructions:</span></p>
  75.       <p align="left"><span class="style8"><span class="style9"> The following sentences are incomplete.Choose the word or phrase that most correctly completes the sentence. </span></span></p>
  76.       <p align="left"> </p>
  77.     </div>
  78.       <table border="0" width="500px" cellspacing="2" cellpadding="4">
  79. <%
  80.  
  81. int i=1;
  82. while(rs.next())
  83. {
  84.  
  85. %>
  86.         <tr>
  87.           <td width="26%"> <strong>Question:<%=i%></strong>.<%=rs.getString(1) %> <input type="text" name="que<%=i%>" style="visibility:hidden" value= "<%= rs.getString(1) %>" /></td>
  88.         <tr>
  89.           <td> <strong>a:</strong>
  90.             <input type="radio" name="q<%=i%>" value= "<%= rs.getString(2)%>"  />
  91.               <%= rs.getString(2) %></td>
  92.         </tr>
  93.         <tr>
  94.           <td> <strong>b:</strong>
  95.             <input type="radio" name="q<%=i%>"  value="<%= rs.getString(3)%>"  />
  96.               <%= rs.getString(3) %></td>
  97.         </tr>
  98.         <tr>
  99.           <td> <strong>c:</strong>
  100.             <input type="radio" name="q<%=i%>" value="<%= rs.getString(4)%>"  />
  101.               <%= rs.getString(4) %></td>
  102.         </tr>
  103.         <tr>
  104.           <td> <strong>d:
  105.             </strong>
  106.             <input type="radio" name="q<%=i%>" value="<%= rs.getString(5)%>"  />
  107.               <%= rs.getString(5) %> </td>
  108.         </tr>
  109.         <tr>
  110.           <td><center>
  111. <%
  112. i++;
  113. }
  114.  
  115. %>
  116.  
  117.               <input type="submit" value="Next" name="submit" />
  118.           </center></td>
  119.         </tr>
  120.       </table>
  121.     <p> </p></td>
  122.   </tr>
  123. </table>
  124.  
  125. </form>
  126. </body>
  127. </html>
  128. <% 
  129.  rs.close();
  130.  pst.close();
  131.  con.close();
  132.  
  133.  
  134. %>
  135.  
  136.  
The problem is wen the function abc is called i,e the timeout happens the radio checked values are not being carried from first jsp to another jsp. so any solution could help me??

Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#2: Jun 15 '09

re: I hav a problem in my online exam code,pls help me


Isn't it considered cheating to ask for help during an exam?
Newbie
 
Join Date: Jun 2009
Posts: 5
#3: Jun 15 '09

re: I hav a problem in my online exam code,pls help me


we r not writing xam,instead v r developing application for it.so its not cheating
Lives Here
 
Join Date: Sep 2006
Posts: 12,070
#4: Jun 15 '09

re: I hav a problem in my online exam code,pls help me


Oh, I get it now.
Well the first thing you must do is not directly related to your current problem.
You need to remove all that Java code from your JSPs. JSPs should not contain any Java code these days.Move all that code to Servlets and utility classes.
Reply