Search code examples
javajavascriptjspservletsjsp-tags

Countdown timer through multiple jsp pages


Hey, I'm developing an online test using servlets/jsps and was wondering how to create a timer that counts down from 6 minutes in which the test will end once it hits zero. Is there a timer class in java that can be used?, if so, how would I implement it in the jsp page?

Any help with this would be greatly appreciated.

P.S. The way I implement the timer doesn't solely have to be the Java language. I have no quarrel using javascript but wasn't sure how to implement it into multiple pages without the counter resetting.


Solution

  • You can go this route:

    When the test is started, put start time in user's session. Afterwards, every time you display a page dealing with test, make sure you have a common part which will be used across these pages.

    At this part, every time a page is clicked, using jsp/servlets, you "push" in remaining time left, and using something like JavaScript countdown, you can elegantly display remaining time without that counter resetting itself.