Want to create a small project for online exam using jsp. As of now I am unable to find, how can I
> Get random questions from mysql database
> Put the timer, so that the exam result is shown automatically after the specified time for exam is over

More queries to follow.

take a look on the following tutorial
http://roseindia.net/jsp/online-quiz-application-jsp.shtml

How can you suggest so awful example?

> Get random questions from mysql database
Depending on database structure. If you have questions organized by unique numeric value, then run random generator for numbers and then collect data from database. Worst case scenario no IDs, then store questions in array list, run random generator and match generated numbers with position in array list

> Put the timer, so that the exam result is shown automatically after the specified time for exam is over
Not sure of this, but I guess it will be done with JavaScript

Depending on database structure. If you have questions organized by unique numeric value, then run random generator for numbers and then collect data from database.

How to generate unique random numbers? If I use Random class, what should I do to ensure that any question isn't repeated?

  • Create a collection of integers (Array - there are some shortcomings to using array, ArrayList, Vector etc.)
  • Provide a loop mechanism that will repeat same process desired number of times
  • Generate random number
  • Compare against collection that this number is not already in collection
  • Depending on result you will either add this number to collection if it doesn't exists or you will request new random number

^OK.Will revert back when I proceed further.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.