How to write Question paper program in jsp....

Hi..,

This is sure from india. I would like to develop online examination project. Everything is ok. But i have a problem at deveop of question paper. I have 10 questions in my database. I would like display those questions one by one. How can i done this job. Please any one guide me. Because, i am new to this concept.

with regards

sure..)-

[367 byte] By [sure_2912a] at [2007-11-26 16:46:38]
# 1

First you need to extract all the question from database..

Then put all of those questions in any of collection object...

Then set this collection object in request as attribute..

Keep this object in request till all question are not shown(you can eliminate questions after the have been asked)..

Code might be like this.

HashMap result = new HashMap();

connection = .......;

Statement stmt=connection.createStatement();

rs = stmt.executeQuery("Your query");

int count=0;

while(rs.next())

{

count++;

String question = rs.getString("colName");

result.put(""+count,question); //( ""+count)>>>>>means converting int to String

}

request.setAttribute("questions",result);

====================================================

now in every JSP which is intended to display a question will have to get this result object..

Lets assume we are about to display first question()....

===========================================

//////// First get result map from request

HashMap questions = (HashMap)request.getAttribute("questions");

String count;

count = request.getAttribute("count");

if(count==null)

count="1";

String question = questions.get(count);

count = new String(""+(Integer.parseInt(count).intValue()+1));

///Now do what you have to do with this questionresult

questions.remove();

request.setAttribute("count",count);////setting question no in request

request.setAttribute("questions",questions);////setting rest of questions in request

===================================================

hope this might be helpful........

if there is any problem you can consult me anytime

rinkua at 2007-7-8 23:14:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Hi..sir. You are so kind of you. Thank u very much your response. I will try this code. If anything i got mistakes. i will send those all.with regardssure...)-
sure_2912a at 2007-7-8 23:14:05 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...