• Post Reply Bookmark Topic Watch Topic
  • New Topic

how to create timer in jsp page ?  RSS feed

 
belleyedan Manikandan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am preparing an online examination s/w using jsp and sql.For each question there must be 60sec after that next question will be automatically retrived from the database.
Also the time has to be shown on top of the page which is decremented every second.On each page there is a next button on clicking, the next question is posed.The timer should be for the whole exam session.

Please help
 
Nathan Pruett
Bartender
Posts: 4121
IntelliJ IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're going to have to do the timer in JavaScript, so that it is actually running in the client's browser, otherwise you're going to have to request tha page every second just to update the timer. You could also have the JavaScript timer do a submit of the page when the timer runs out so that the next question can be retrieved.

But you shouldn't rely on the JavaScript timer in your server side code - the user could disable JavaScript (and the Timer) or be smart enough to provide fake timer data. But you also don't have to run a real-time timer on the server either, just keep a timestamp in the session for the user. Set it when a question is sent to the user, check the time when the user submits their answer against it to make sure it falls within the time constraints.
 
belleyedan Manikandan
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Nathan.I did that timer successfully.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!