Introducing Radical.sh

Forget Code launches a powerful code generator for building API's

Create three-tier applications using JSP and Databases for conducting on-line examination and displaying student mark list in Java

Steps for Creating DataSource for Microsoft Access drivers
1.Go to Control Panel and Select Administrative Tools and then select Data Source ODBC icon.
(or)
1.Go to Run(Press Window+R) and type odbcad32.exe to go Data Source ODBC.
2.Press Add Button.
3.Choose the driver for Microsoft Access.
4.Then,Press Finish Button.
5.Type Data Source Name as ExamStudent.
6.Then Press "Select Button" and choose the database file which is created already.
7.Then, Press "OK" Button to complete the process.


Steps for Creating Database and table for this Program:
1.Create Ms Access File in any Name
2.Then Open it .
3.Create the table in the name of StudentTable With following columns Seat_no,Name,Marks

Schema for the Table:
Field nameDataType
Seat_noNumber
NameText
MarksNumber

  1. // OnlineExam.jsp
  2. <%@ page language="java" import="java.sql.*" %>
  3. <%@ page import="java.io.*" %>
  4. <%@ page import="java.util.*" %>
  5.  
  6. <%
  7. String SeatNum,Name;
  8. String ans1,ans2,ans3,ans4,ans5;
  9. int a1,a2,a3,a4,a5;
  10. a1=a2=a3=a4=a5=0;
  11. Connection connect=null;
  12. Statement stmt=null;
  13. ResultSet rs=null;
  14. Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
  15. String url = "jdbc:odbc:ExamStudent";
  16. connect = DriverManager.getConnection(url," "," ");
  17. if(request.getParameter("action")!=null)
  18. {
  19. SeatNum = request.getParameter("Seat_no");
  20. Name = request.getParameter("Name");
  21. ans1 =request.getParameter("group1");
  22. if(ans1.equals("True"))
  23. a1=5;
  24. else
  25. a1=0;
  26. ans2 = request.getParameter("group2");
  27. if(ans2.equals("True"))
  28. a2=0;
  29. else
  30. a2=5;
  31. ans3 = request.getParameter("group3");
  32. if(ans3.equals("True"))
  33. a3=0;
  34. else
  35. a3=5;
  36. ans4 = request.getParameter("group4");
  37. if(ans4.equals("True"))
  38. a4=5;
  39. else
  40. a4=0;
  41. ans5 = request.getParameter("group5");
  42. if(ans5.equals("True"))
  43. a5=0;
  44. else
  45. a5=5;
  46. int Total=a1+a2+a3+a4+a5;
  47. stmt = connect.createStatement();
  48. String query = "INSERT INTO StudentTable (" + "Seat_no,Name,Marks" + ")
  49. VALUES ('" +SeatNum + "', '" + Name + "', '"+Total+ "')";
  50. int result = stmt.executeUpdate(query);
  51.  
  52. stmt.close();
  53. stmt = connect.createStatement();
  54. query = "SELECT * FROM StudentTable WHERE Name="+"'"+Name+"'";
  55. rs = stmt.executeQuery(query);
  56. %>
  57. <html><head><title>Student Mark List</title></head>
  58. <body bgcolor=khaki>
  59. <center>
  60. Students Marksheet

  61. Name of the College : JCE College of Engineering

  62. <table border="1" cellspacing="0" cellpadding="0">
  63. <tr>
  64. <td><b>Seat_No</b></td>
  65. <td><b>Name</b></td>
  66. <td><b>Marks</b></td>
  67. </tr>
  68. <%
  69. while(rs.next())
  70. {
  71. %>
  72. <tr>
  73. <td><%=rs.getInt(1)%></td>
  74. <td> <%=rs.getString(2)%></td>
  75. <td> <%=rs.getString(3)%></td>
  76. </tr>
  77. <%
  78. }
  79. rs.close();
  80. stmt.close();
  81. connect.close();
  82. %>
  83. </table>
  84. </center>
  85. <br/> <br/><br/>
  86. <table>
  87. <tr><td><b>Date:<%=new java.util.Date().toString() %></td></tr>
  88. <tr><td><b>Signature: X.Y.Z. <b></td></tr>
  89. </table>
  90. <div>
  91. Click here to go back
  92. </body>
  93. </html>
  94. <%}else{%>
  95. <html>
  96. <head><title>Online Examination</title>
  97. <script language="javascript">
  98.  
  99. function validation(Form_obj)
  100. {
  101. if(Form_obj.Seat_no.value.length==0)
  102. {
  103. alert("Please,fill up the Seat Number");
  104. Form_obj.Seat_no.focus();
  105. return false;
  106. }
  107. if(Form_obj.Name.value.length==0)
  108. {
  109. alert("Please,fill up the Name");
  110. Form_obj.Name.focus();
  111. return false;
  112. }
  113. return true;
  114. }
  115. </script>
  116. </head>
  117. <body bgcolor=lightgreen>
  118. <center>
  119. Online Examination

  120. </center>
  121. <form action="OnlineExam.jsp" method="post"
  122. name="entry" onSubmit="return validation(this)">
  123. <input type="hidden" value="list" name="action">
  124. <hr/>
  125. <table>
  126. <tr>
  127. <td>

    Seat Number :

    </td>
  128. <td><input type="text" name="Seat_no"></td>
  129. </tr>
  130. <tr>
  131. <td>

    Name :

    </td>
  132. <td><input type="text" name="Name" size="50"></td>
  133. </tr>
  134. <tr>
  135. <td><b>Total Marks:5*5=25 </b></td>
  136. <td></td><td></td><td></td><td><b>Time: 15 Min.</b></td>
  137. </tr>
  138. </table>
  139. <hr/>
  140. <b>1. XML enables you to collect information once and reuse it in a
  141. variety of ways.</b><br/>
  142. <input type="radio" name="group1" value="True">True
  143. <input type="radio" name="group1" value="False">False<br>
  144. <br/>
  145.  
  146. <b>2. In Modern PC there is no cache memory.</b><br/>
  147. <input type="radio" name="group2" value="True">True
  148. <input type="radio" name="group2" value="False">False<br>
  149. <br/>
  150. <b>3. JavaScript functions cannot be used to create script fragments
  151. that can be used over and over again</b><br/>
  152. <input type="radio" name="group3" value="True">True
  153. <input type="radio" name="group3" value="False">False<br>
  154. <br/>
  155. <b>4.The DriverManager class is used to open a connection to a
  156. database via
  157. a JDBC driver.</b><br/>
  158. <input type="radio" name="group4" value="True">True
  159. <input type="radio" name="group4" value="False">False<br>
  160. <br/>
  161. <b>5. The JDBC and ODBC does not share a common parent</b><br/>
  162. <input type="radio" name="group5" value="True">True
  163. <input type="radio" name="group5" value="False">False<br>
  164. <hr/>
  165. <center>
  166. <input type = "submit" value="Submit">
  167. <input type = "reset" value="Clear"><br><br>
  168. </center>
  169. </form>
  170. <%}%>