Monday, 26 March 2012

online examination using jsp

) ONLINE EXAMINATION USING JSP

AIM:
      To create a  three tier application for conducting online examination using JSP and database.

ALGORITHM:
1.       Design the HTML page (ExamClient.html) with the following
a)      Create a form to get the input from the user.
b)      Use radio buttons to make various options for the questions.
c)       Set the URL of the server (ExamServer.jsp) as the value of the action attribute.
d)       Use submit button to invoke the server and send the form data to the server.
2.       Create the JSP file with the following
a)       Read the input from the client.
b)       Retrieve the answers from the database.
c)       Match the answers from the user with the correct answers from the database table.
d)       For each correct answer increment the mark by 5.
e)       Server displays the mark and result to the client as a response.

PROGRAM:

ExamClient.html

<html>
<head>
<title>Online Exam Client</title>
<style type="text/css">
   body{background-color:black;font-family:courier;color:blue}
</style>
</head>
<body>
<h2 style="text-align:center">ONLINE EXAMINATION</h2>
<h3>Answer the following questions (5 marks for each correct answer)</h3>
<hr/>
<form name="examForm" method="post" action="ExamServer.jsp">
1.Who is called as the father of computer?<br/>
<input type="radio" name="ans1" value="Sachin">Sachin
<input type="radio" name="ans1" value="Stuart">Stuart
<input type="radio" name="ans1" value="Charles Babbage">Charles Babbage
<input type="radio" name="ans1" value="Napier">Napier
<br/><br/>
2.C++ was developed by?<br/>
<input type="radio" name="ans2" value="Dennis Ritchie">Dennis Ritchie
<input type="radio" name="ans2" value="None">None
<input type="radio" name="ans2" value="David Ritchie">David Ritchie
<input type="radio" name="ans2" value="John">John
<br/><br/>
3.C was developed by?<br/>
<input type="radio" name="ans3" value="Dennis Ritchie">Dennis Ritchie
<input type="radio" name="ans3" value="Stroustrup">Stroustrup
<input type="radio" name="ans3" value="David Ritchie">David Ritchie
<input type="radio" name="ans3" value="Charles Babbage">Charles Babbage
<br/><br/>
<input type="submit" value="Check Your Result"/>
</form>
</body>
</html>

ExamServer.jsp

<%@page contentType="text/html" language="java" import="java.sql.*"%>
<html>
<head>
<title>Online Exam Server</title>
<style type="text/css">
   body{background-color:black;font-family:courier;color:blue}
</style>
</head>
<body>
<h2 style="text-align:center">ONLINE EXAMINATION</h2>
<p>
<a href="ExamClient.html">Back To Main Page</a>
</p>
<hr/>
<%
String str1=request.getParameter("ans1");
String str2=request.getParameter("ans2");
String str3=request.getParameter("ans3");
int mark=0;
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
Connection con=DriverManager.getConnection("jdbc:odbc:examDS");
Statement stmt=con.createStatement();
ResultSet rs=stmt.executeQuery("SELECT * FROM examTab");
int i=1;
while(rs.next())
{
 if(i==1)
 {
  String dbans1=rs.getString(1);
  if(str1.equals(dbans1))
  {
   mark=mark+5;
  }
 }
 if(i==2)
 {
  String dbans2=rs.getString(1);
  if(str2.equals(dbans2))
  {
   mark=mark+5;
  }
 }
 if(i==3)
 {
  String dbans3=rs.getString(1);
  if(str3.equals(dbans3))
  {
   mark=mark+5;
  }
 }
 i++;
}
if(mark>=10)
{
 out.println("<h4>Your Mark Is : "+mark+"</h4>");
 out.println("<h3>Congratulations....! You Are Eligible For The Next Round...</h3>");
}
else
{
 out.println("<h4>Your Mark is : "+mark+"</h4>");
 out.println("<h3>Sorry....!! You Are Not Eligible For  The Next Round...</h3>");
%>
</form>
</body>
</html>
 
Database Name: examDB.accdb
Table Name: examTab

11 comments:

  1. how to upload comment in online

    ReplyDelete
  2. Need a output

    Please help me

    ReplyDelete
  3. Thanks To sharing blog Excellent information with us...
    sparkinfosys
    Sparkinfosys is one of the best company in hyderabad ,We provide Features of online Examination website designed and developed by Spark Infosys Hyderabad. Spark Infosys provides online exam portal development etc..

    ReplyDelete
  4. What makes FollowClass online examination software different from other school app providers is described clearly in the below table. But one factor which can be defined in any table is is our customer support for our online examination portal. We treat our customers like god. So give us a chance to serve you and get the best possible online examination portal your coaching institute.

    ReplyDelete
  5. its not work...try to give some other solution to us

    ReplyDelete
  6. My own perspectives are coordinating with creator and I have encountered such. Your blog is extremely instructive. Online test series for gate 2020

    ReplyDelete
  7. Excellent and very cool idea and the subject at the top of magnificence and I am happy to comment on this topic through which we address the idea of positive re like this. Online Exam Software

    ReplyDelete