Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JSP-Servlet online examination
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Arti Hanuman Maurya
online examination
1 Answer(s)      2 years and 8 months ago
Posted in : JSP-Servlet


coding for multiple choice question in jsp


Advertisement
View Answers

February 1, 2012 at 10:54 AM


We are providing you a simple application.

Create table test(ques,op1,op2,op3,op4,ans) and answers(id,ans).

Then try the following code:

1)form.jsp:

<%@page import="java.sql.*"%>
<html>
<form method="post" action="result.jsp">
<table>
<%
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement st=connection.createStatement();
ResultSet rs=st.executeQuery("Select * from test");
int i=1;
while(rs.next()){
%>
<tr><td><%=i%></td><td><%=rs.getString("ques")%></td><td><input type="radio" value="<%=rs.getString("op1")%>" name="radio<%=i%>"/><%=rs.getString("op1")%></td><td><input type="radio" value="<%=rs.getString("op2")%>" name="radio<%=i%>"/><%=rs.getString("op2")%></td><td><input type="radio" value="<%=rs.getString("op3")%>" name="radio<%=i%>"/><%=rs.getString("op3")%></td><td><input type="radio" value="<%=rs.getString("op4")%>" name="radio<%=i%>"/><%=rs.getString("op4")%></td></tr>

<%
i++;
}
%>
<tr><td><input type="submit" value="submit"></td></tr>
</table>
</form>
</html>

2)result.jsp:

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

<%
String st[]=new String[10];
for(int i=0;i<st.length;i++){
int j=i+1;
st[i]=request.getParameter("radio"+j);
System.out.println(st[i]);

}
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection connection = DriverManager.getConnection("jdbc:mysql://localhost:3306/register","root";, "root");
Statement stmt=connection.createStatement();
ResultSet rs=stmt.executeQuery("Select ans from answers");
String ans="";
while(rs.next()){
ans+=rs.getString("ans")+" ";
}
int count=0;
String answers[]=ans.split(" ");
for(int i=0;i<answers.length;i++){
if(st[i].equals(answers[i])){
count++;
}
}
out.println("Your "+count+" answers are correct");
%>

For more information, visit the following link:

http://www.roseindia.net/jsp/online-quiz-application-jsp.shtml



Related Tutorials/Questions & Answers:
online examination
online examination  Hi, i am doing online examination project, i have some problem with get a paper form database and count the right answer and display the result. So, i request to you please help me come out to this problem
online examination
online examination  coding for multiple choice question in jsp   We are providing you a simple application. Create table test...: http://www.roseindia.net/jsp/online-quiz-application-jsp.shtml
Advertisements
online examination system project in jsp
online examination system project in jsp  How to show the status bar which shows how much time is remaining in online examination system in jsp.my
Java project in online examination system
Java project in online examination system  how many and which tables are required at backend as SQL for online examination system project in jsp
online examination system project in jsp
online examination system project in jsp  How many tables are required in SQL for online examination system project in jsp in java
online examination system project in jsp
online examination system project in jsp  How many tables are required in SQL for online examination system project in jsp in java my email id
Online Examination System
Online Examination System  Hi.. I have to create a Online Examination system using struts, Hibernate and stateful session beans.. I Wanna know the use of stateful session beans in project
online examination system project in jsp
online examination system project in jsp  How many and which data tables are required for online examination system project in jsp in java. please give me the detailed structure of each table
online examination system project in jsp
online examination system project in jsp  thanks for providing me 6 tables for online examination system. I want to know what will the id field of Answers1 table contain? Will it contain same id for all the questions of Set1 &
online examination system project in jsp
online examination system project in jsp  thanks for providing me 6 tables for online examination system. I want to know what will the id field of Answers1 table contain? Will it contain same id for all the questions of Set1 &
online examination system project in jsp
online examination system project in jsp  Thanks for providing me the 6 tables.But I want to know will the id field of answers1 table be same for all questions of Set1? Will it be 1 or will be 1,2,3,... What
servlet doubt on online examination system
servlet doubt on online examination system  hai. sir ,i am doing project in online examination system. taken back end as mysql database. and doing the programs using java servlet. MY PROBLEM and doubt is 1. how 2 skip
online examination system project in jsp
online examination system project in jsp  I am doing project in online examination system in java server pages. plz send me the simple source code in jsp for online examination system
online examination system mini project
online examination system mini project  i developed a project on online examination system using jsp and java script . I am getting the quetion...; For more information, visit the following link: Struts Online Test Application
How to insert and retrieve Questions with special symbols and images into database in an ONLINE EXAMINATION project?
How to insert and retrieve Questions with special symbols and images into database in an ONLINE EXAMINATION project?  Hi guys. I am developing an online examination application. I am using JSP,MYSQL and ECLIPSE .The problem
On line examination project
On line examination project  Hi, I am doing project in jsp,nam eis online examination project. I am facing some problems. In my database several...-Servlet/7578-creation-of-a-form.html http://www.roseindia.net/jsp/online-quiz
SECURE EXAMINATION SYSTEM
SECURE EXAMINATION SYSTEM  Hello sir,if any online exam is held then we register with username and password and starts the exam with the question one by one within countdown session that is within timer out.If the system failure
create examination slip for students
create examination slip for students  hello,can anyone help me how to create examination slip that include subject code,courses,credit hours,grade ,and status
Prometric Centers AND Examination Timing
Prometric Centers AND Examination Timing  Please provide me list of prometric centers in mumbai for SCJP and also date & time for the examination. Thank You In Adv
on-line examination project?(urgent pls)
on-line examination project?(urgent pls)  Hello friends, i am doing an on-line examination project. In A page i will get n(user requirement) questions from data base(question and five radio buttons) if the user had
online test system
online test system  Hi, I am creating a project for online test.../online-quiz-application-jsp.shtml http://www.roseindia.net/answers/viewqa/JSP-Servlet/15400-online-examination-system-project-in-jsp.html http
online voting
online voting  can i have the code for online voting in java
online bookbank
online bookbank  Need online book bank with mvc architecture
online voting
online voting  can i have the code for online voting in java
online shopping
online shopping  hi, i am doing online shopping project i want to do online payment. How it can be possible
Online exam using c# and SQL server
Online exam using c# and SQL server  hello, i'm making the (window based)online examination system using C#.net and SQL SERVER. my database is stored on server. my question is: if during the examination server gets failed
online exam
online exam  how we can upload the data on the server using any site
online exam
online exam  how we can upload the data on the server using any site
online shopping
online shopping   Hai sir/madam, i'm working on online shopping project.requirements is oracle10g,servlets/jsp... what is the difference b/w storing and saving image into database.how to store and how
online exam
online exam  Write a program to determine if an input string x is a substring of another input string y. For example, a "bat" is a substring of "abate" but not a substring of "beat
Online Exam
Online Exam  I want to write a program for Exam with multiple answers program can read answers one by one and it shows the total marks at the end how it can implement Help me
Advertisements
 

 

 

DMCA.com