Need Help in creating online quiz application using JSP

Ads

 
 

Share on Google+Share on Google+

ganesh
Need Help in creating online quiz application using JSP
3 Answer(s)      8 years ago
Posted in : JSP-Servlet
Ads
View Answers

November 21, 2008 at 7:13 AM


Hi friend,


<%@ page import="java.sql.*" %>

<!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>JSP Page</title>
</head>
<body>
<%
String ans=" ";
if(request.getParameter("correctAns")!=null)
{
ans=request.getParameter("correctAns").toString();
}


Connection conn = null;
String driver = "com.mysql.jdbc.Driver";
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String user = "amar";
String pass = "amar123";
Statement st = null;
ResultSet qrst;
ResultSet rs = null;

String id=request.getParameter("id");

System.out.println("id:"+id);

int i=1;

String s,g;

int count=0;

try {

Class.forName(driver);
conn = DriverManager.getConnection(url+db,user,pass);

st = conn.createStatement();
//for(i=1;i<=2;i++)
// {
rs = st.executeQuery("select * from question_deatil");

while(rs.next()) {
%>

<br>
<br/>
<center>

<table border="1" width="500px" bgcolor="pink" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">

<form name="form1">

<h2 align="center"><font color="red">Online Quize Application</font></h2>

<b>Select Correct Answer</b>
<table border="0" width="500px" cellspacing="2" cellpadding="4">
<tr>

<td width="50%"> Question:</td>
<input type="hidden" name="correctAns" value="<%=rs.getString(7)%>" />
<tr>
<td><%= rs.getString("quest") %></td></tr>
<tr>
<td>

1: <input type="radio" name="a" value= "QA" /></td>
<td><%= rs.getString("QA") %></td></tr>
<tr>
<td>
2: <input type="radio" name="a" value="QB" /></td>
<td><%= rs.getString("QB") %></td></tr>

<tr>
<td>
3: <input type="radio" name="a" value="QC" /></td>
<td><%= rs.getString("QC") %> </td></tr>

<tr>
<td>
4: <input type="radio" name="a" value="QD" /> </td>
<td> <%= rs.getString("QD") %> </td></tr>

<tr>
<td>
<center>
<input type="submit" value="Submit" name="submit"></center></td></tr>
</table>

</form>
</td>
</tr>
</table>
</center>
</body>
<% g=request.getParameter("a");
%>
<%
if(g.equals(ans)){

count++;
out.println("Correct");

}
else
out.println("false");
%>



<%
}}
// }
catch (Exception ex) {
ex.printStackTrace();


%>

<%
} finally {
if (rs != null) rs.close();
if (st != null) st.close();
if (conn != null) conn.close();
}
out.println("Score="+count);
%>

</html>


November 21, 2008 at 7:15 AM


<[email protected] language="java" import="java.sql.*" %>



<%
if(request.getParameter("submit")!=null)
{

Connection con = null;
String url = "jdbc:mysql://192.168.10.211:3306/";;
String db = "amar";
String driver = "com.mysql.jdbc.Driver";
String userName ="amar";
String pass="amar123";



try{

Class.forName(driver);

con = DriverManager.getConnection(url+db,userName,pass);



try{

Statement st = con.createStatement();

String quest = request.getParameter("quest").toString();
String QA = request.getParameter("QA").toString();
String QB = request.getParameter("QB").toString();
String QC = request.getParameter("QC").toString();
String QD = request.getParameter("QD").toString();
String correctAns = request.getParameter("correctAns").toString();
out.println("quest : " + quest);

String qry = "insert into question_deatil(quest,QA,QB,QC,QD,correctAns) values('"+quest+"','"+QA+"','"+QB+"','"+QC+"','"+QD+"','"+correctAns+"')";

out.println("qry : " + qry);



int val = st.executeUpdate(qry);

con.close();
if(val>0)
{
response.sendRedirect("quizeApplication.jsp");
}



}



catch(SQLException ex){

System.out.println("SQL satatment not found");

}

}

catch(Exception e){

e.printStackTrace();

}
}


%>


November 21, 2008 at 7:16 AM



<html>
<title>Quize application in jsp</title>
<head>

<script>

function validateForm(theForm){



if(theForm.quest.value==""){

//Please enter username

alert("Please enter Question.");

theForm.quest.focus();

return false;

}

return true;
}
</script>
</head>

<body>
<br>
<br/>
<center>

<table border="1" width="450px" bgcolor="pink" cellspacing="0" cellpadding="0">
<tr>
<td width="100%">
<form method="POST" action="" onsubmit="return validateForm(this);">

<h2 align="center"><font color="red">Quize Application in JSP</font></h2>
<table border="0" width="400px" cellspacing="2" cellpadding="4">
<tr>
<td width="50%"><b>Enter Question:</b></td>
<td width="50%"><input type="text" name="quest" size="40"/> </td>
</tr>
<tr>
<td width="50%"><b>Enter Answer(A.):</b></td>
<td width="50%"><input type="text" name="QA" size="40"/> </td>
</tr>
<tr>
<td width="50%"><b>Enter Answer(B.):</b></td>
<td width="50%"><input type="text" name="QB" size="40"/> </td>
</tr>

<tr>
<td width="50%"><b>Enter Answer(C.):</b></td>
<td width="50%"><input type="text" name="QC" size="40"/> </td>
</tr>

<tr>
<td width="50%"><b>Enter Answer(D.):</b></td>
<td width="50%"><input type="text" name="QD" size="40"/> </td>
</tr>

<tr>
<td width="50%"><b>Correct Answer:</b></td>
<td width="50%"><input type="text" name="correctAns" size="10"/> </td>
</tr>

</table>
<center>
<p><input type="submit" value="Submit" name="submit">
<input type="reset" value="Reset" name="reset"></p>
</center>
</form>
</td>
</tr>
</table>
</center>
</body>

</html>

--------------------------------

Read for more information.

http://www.roseindia.net/jsp/

Thanks.

Ads









Related Tutorials/Questions & Answers:
Need Help in creating online quiz application using JSP - JSP-Servlet
Need Help in creating online quiz application using JSP  Hi, i am creating online Quiz application using JSP and MySQl ,Apache 6 in Netbeans IDE. i..., JSP Page Online Quize Application
Online Quiz Application in JSP
are going to implement of Online quiz application using of JSP. Step 1: Create... Online Quiz Application in JSP  ... quiz question and answer form using with JSP or JDBC database.  Here
Advertisements
Failed to run Online Quiz Application in JSP - JSP-Interview Questions
Failed to run Online Quiz Application in JSP   Hi, I have been following your following link to run the online quiz application, but I failed... your question. Thanks  Hi, I cannot run your online quiz
How to provide navigation in quiz application using jsp?
How to provide navigation in quiz application using jsp?  hi everyone. i am using jsp with mysql connectivity. i have to retrieve questions from db one at a time. on clicking the next it should go the next question
How to Create Quiz Application using iPhone
How to Create Quiz Application using iPhone  Hi, I am learning iphone application Programming Language. my question is that how to create a quiz application using iPhone. Please provide online reference to study and example
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.
online quiz program coding using jsp, jdbc odbc connection with ms. access.. Thank you.  please provide online quiz program coding using jsp, jdbc...: http://www.roseindia.net/jsp/online-quiz-application-jsp.shtml
Online quiz mini project
Online quiz mini project  Sir i need a online quiz program coding using java servlet, jdbc odbc connection with ms. access. If possible send that source code to me. Thank you
online quiz
online quiz  Define a Question class which stores a multiple choice...) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question
online quiz
online quiz  Define a Question class which stores a multiple choice...) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question
online quiz
online quiz  Define a Question class which stores a multiple choice...) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question
online quiz
online quiz  Define a Question class which stores a multiple choice...) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question
online quiz
online quiz  Define a Question class which stores a multiple choice...) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question
online quiz
online quiz  Define a Question class which stores a multiple choice...) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method of the Quiz class to add a question
problem in creating web application using servelet, jsp, jdbc and xml - JSP-Servlet
problem in creating web application using servelet, jsp, jdbc and xml  Using Servlet, JSP, JDBC and XML create a web application for a courrier company to provide online help in tracking the delivery status of items.  
Online quiz mini project
Online quiz mini project  Hi. I follow one of the code for "Online quiz mini project". I would like to know how to count the number of wrong answers in jsp
Need help on JAVA JSP
Need help on JAVA JSP  Hi, I have never worked on java and I have... using JAVA JSP). e.g. Tool does not adjust with the resolution of the screen(need to know how I can adjust it based on the cureen system's screen resolution
online shopping code using jsp
online shopping code using jsp  plz send me the code of online shopping using jsp or jdbc or servlets plz plz help me
beginner need help with online ordering program please
beginner need help with online ordering program please  I have created a program for an online ordering system and now have to add error handling and a few other things my teacher doesn't teach well is there a template I can go
need help creating a lift program - Java Beginners
need help creating a lift program  Classes, Methods, Constructors please i need help to create an elevator program Simulating an Elevator write... and how methods manipulate the data of an object. 1. Using (JCreator), write
Need some help creating an order form.
Need some help creating an order form.  Hi there. I am looking to create an order form for clients to customize the way a product looks. The codes I found on the form html page are useful. My question is: can I tie them all
need help to remove and optimise the code for creating a page
need help to remove and optimise the code for creating a page   i have the following code but it has some sorts of error whenever i run the page after validation through javascript it calls for the servlets and then i tried
JAVASCRIPT FOR ONLINE QUIZ
JAVASCRIPT FOR ONLINE QUIZ  i m creating a set of online questionnaire consist of 12 questions with choice of answers from 0-6.i've done creating... to modify to include get element id function.I REALLY NEED YOUR HELP IN THIS.PLS
online test software using jsp and servlet
online test software using jsp and servlet  online test software using jsp and servlet
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM
CAN U HELP ME TO CODE IN JSP FOR ONLINE VOTING SYSTEM  can u help me to code in jsp for online voting system
Using Servlets, JSP for Online Shopping
Using Servlets, JSP for Online Shopping  What is wrong with my code ? JSP <form action="LoginServlet "method="post" > <table> <tr ><td>Username:</td><td><input type="text" name="Id
need to open a file that is in server using jsp
need to open a file that is in server using jsp   im doing a web application where i can upload and download pdf files from server.in this i created... open link it should be opened in jsp.downlaoding part was done by me. wt i need
application using AJAX and JQuery and also use JSP
application using AJAX and JQuery and also use JSP   i need create an application using AJAX and JQuery and also use JSP
online test project on java using servlets and jsp
online test project on java using servlets and jsp  as i am doing online test project on java using jsp and servlets ,,,the problem is in the code...;Here is a jsp application. Here we have created a table test
Need help to create Struts 2 MySQL based HRMS application.
Need help to create Struts 2 MySQL based HRMS application.   Hi Sir, I am doing my project based on Human Resource Management system using struts 2... given here. Some are working but some are not. Can you please help me to create
New to JSP..need help to make & run a JSP program.
New to JSP..need help to make & run a JSP program.  Hi, I have installed Tomcat 5.5 on my system. Plz help me to make a simple JSP program... appropriate name to web application folder like examples and put jsp file
Need help in image uploading - JSP-Servlet
Need help in image uploading  hii, i have one doubt in uploading an image in jsp. I want to display image from DB to my jsp page. For that i... a folder named images in server but cant upload.Is any extra code need for uploading