• CONTEST ALERT - Experience the power of DDR5 memory with Kingston Click for details

Need Help in creating online quiz application using JSP

Not open for further replies.


i am creating online Quiz application using JSP and MySQl ,Apache 6 in Netbeans IDE.
i am able to successfully display first question from database,and can say the answer is correct or not,,but i can't implement the program further ,in such way that when clicking next button ,new question gets displayed and score calculated there after!,
Document : start
Created on : Nov 16, 2008, 2:58:18 PM
Author : Ganesh
<%@ page import="java.sql.*" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>JSP Page</title>
<% String ans=" ";
Connection conn = null;
Statement st = null;
ResultSet rs = null;
int i=1;
String s,g;
int count=0;
try {

conn =

st = conn.createStatement();
// {
rs = st.executeQuery("select * from quiz where n="+i);

while(rs.next()) {

<form name="form1">

<h3> <%= rs.getString("quest")%></h3>

1: <%= rs.getString("a") %> <input type="radio" name="a" value= "a" />

2: <%= rs.getString("b") %> <input type="radio" name="a" value="b" />

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

4: <%= rs.getString("d") %> <input type="radio" name="a" value="d" />
<input type="submit" value="OK">

<% g=request.getParameter("a");
<% ans= rs.getString("ans");


// }
catch (Exception ex) {


} finally {
if (rs != null) rs.close();
if (st != null) st.close();
if (conn != null) conn.close();

contents of database
mySql-->select * from quiz;
quest a b c d e ans
What is capital of india Chennai Mumbai Delhi bangalore c 1
What is capital of tamil nadu Chennai madurai trichy coim a 2
i need Some ideas to build this project !!!


In the zone
what you are doing is not a best practice you should write business logic in java
try Struts 2 it is quite easy to learn and very effective in developing any kind of application in very short time.


In the zone

What Desi-Tek told is right. What you are doing is completely bad way of doing it and IMHO it is a reason you are stuck. Even if you don't want to use any framework, I'd suggest you to read up on MVC architecture. It will make your life a breeze once you learn.

A simple MVC for your case would be writing a servlet, which invokes quiz validation code from another simple class. All JSPs can post to this servlet and the servlet should dispatch to appropriate JSP after validation.

I personally like not using frameworks for simple apps and for complex apps I prefer JSF.
Not open for further replies.
Top Bottom