Hi,
I am developing online examination in servlets/jsp.
the problem with I stucked with is how to show user a timer.
the jsp page which showing current question to user should show time remaining & that time should be continuously decreasing by 1 sec.
One approch is to use applet sychronized with session attribute storing current time.

But how to get value in applet from session attribute.

OR
is there a better way to show time in online environment.

Please guide me as soon as possible.

You can use JavaScript for displaying timer and there is no need for binding it with a session. Rather, as soon as the user will click start exam button and the jsp page with questions is diplayed, the timer will start executing. When the user ends the exam, the timer will stop and you can display the total time. In order to monitor the time taken by user in the exam, you can pass the start time and to a Servlet where you can check whether the user has exceeded the time. If user has exceeded the time, ask a servlet to end the exam. You can put the timer in a separate Jsp page and use <jsp:include> to include it with the Jsp with questions

You are assuming smooth execution. What happens if the browser is closed when taking the exam? What happens when the user refreshes the page? You need to maintain the user state as well as the time of the examination in the user session. Keep the involvement of Javascript in business logic to its minimum.

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.