Need Help in creating online quiz application using JSP

Need Help in creating online quiz application using JSP

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

<%@page 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.









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
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
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
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
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
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 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 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 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 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
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 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
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
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
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
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... application folder like examples and put jsp file into it. Then start the tomcat server
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
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
Need help
Need help  Dear sir, I have a problem. How to write JSP coding.... This name list should get from the database. Please help me. By the way, I'm using access database and jsp code. Thank you
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
Need to develop a control panel for application form which is developed in jsp
Need to develop a control panel for application form which is developed in jsp  I have created one application page which contains some check boxes,radio buttons and text boxes in jsp this for user to fill it. Now I need
Re:Need Help for Editable Display table - JSP-Servlet
Re:Need Help for Editable Display table  Hi Genius i need a help in jsp to display editable display tag. I able to show the datagrid in jsp but i cant edit in that. My backend is with Mysql. I need to fetch the data
code to send sms alerts using jsp online
code to send sms alerts using jsp online  I am new to mobile aplication development. pls send me the code for sms alerts after clicking the button
Re:Need Help for Editable Display table - JSP-Servlet
Re:Need Help for Editable Display table  Hi Genius
i want to do a project using jsp and servlet....What are all the materials i need to study
need to study   i want to do a project using jsp and servlet....What... links: JSP shopping cart Struts Shopping Cart Struts Online test application JSP Online test application   Please visit the following links: JSP
how to create chat application in jsp?
Creating Chat application in JSP  Creating Chat application in JSP i am developing online web portal using jsp, i need to communicate with admin, so i need integrate with the chat applicaion through the webportal
Need help with this!
Need help with this!  Can anyone please help me... to a file at all at this time. Any help would be greatly appreciated, thank you...)); //creating arrays int [][] score = new int[27][50]; int
need complete jsp code for transactions using mysql - WebSevices
need complete jsp code for transactions using mysql  iam doing online banking project.i want the code to transfer funds from one account to another... to lasya or lasya to prathika. I need complete jsp code for transactions using
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
Need help
Need help  Hello... I need some help I have a method which contains 1 string value and i wnat when this method get called den that string value should b assigned as array name.. for example.. i have a method name() which
need help please
need help please  Dear sir, my name is logeswaran. I have a big... enter a page second time. Please help me. By the way I'm using Access database and JSP coding Thank you
need a sample project using java technologies like jsp, servlets, struts
need a sample project using java technologies like jsp, servlets, struts  Hi everybody! I have learnt core java,jdbc,jsp,servlets & struts... other project with detailed explanation using the above technologies by which i
online banking application
online banking application  i want to develope online banking application by using jsp with oracle 10g database but i have problem to view the mini... this ... plz send coding in jsp by using oracle 10g database
jsp online ex
jsp online ex  plz help me providing source code for mini project online exam using jsp and mysql..... plzplz plzhelp me pur
jsp online ex
jsp online ex  deepak sir please help me...i jave created jsp page containing a question with 4 optipns and now i want tp save the options selected... help me out plzzzzzzzzzzz i need it urgently
quiz
quiz  using core java concepts purely not html ,Define a Question... question has a complexity (difficulty) level. Use the Question class to define a Quiz class. A quiz can be composed of up to 10 questions. Define the add method
Need Help on JMS - JMS
Need Help on JMS   Hi, In my application i need to create my own ques and my own QueueConnectionFactory..... Plz tell me how to create the same... Any help is appriciated,.. Thanks in advance
need help....how to connect and disconnect multiple databases(databases created in mysql) using java and my sql
need help....how to connect and disconnect multiple databases(databases created... on deadlock in distributed transactions , and in that i am using my sql in java i need... such program if u can provide me...plz plz...help i need the idea/code/implementation

Ads