I am preparing an online examination s/w using jsp and oracle.For every exam session there is a fixed time to be kept eg. 30 mins after which the page should become inactive.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.after the timer expires the form should automatically expire Please help.
I see no way how you can solve this with a JSP, Javascript would help here if a counter decrements and submits the form after 30 minutes.
Winston Smith
Ranch Hand
Joined: Jun 06, 2003
Posts: 136
posted
0
You can use an applet to control the timer, but I try to stay away from applets (it's been so long, I've even forgotten the reason why). Or, you can use javascript to control the timer, and after, say 25 minutes, you can bring up an alert box saying "5 mins. left" or whatever, then at 30 minutes, you redirect them to an exam completion page. The trick about this method is...you cannot leave the page because the javascript timer exists only at the page level, and once you leave the page, it is lost (unless you store the value in a form, submit to next page, etc. but this really will not work if we're talking about a timer. So, basically, try to keep your exam limited to one page. You may be able to use an IFRAME to scroll through pages, keeping the timer info on the parent page, or you can simply have the exam all on one page. Either way, this probably does not involve JSP as much as javascript and some good HTML design work.
for (int i = today; i < endOfTime; i++) { code(); }
Bear Bibeault
Author and opinionated walrus
Marshal
There is a problem with using JavaScript to do this... The person can disable it and the timer will not work. But this is what you really need to: On the server side you have to put a validation to check the time. If the time is greater then the time limit plus a little extra time for processing, then you just do not allow it to submit and give a zero or something to that affect. (You might put a disclaimer stating that.)
With javascript you just need to use a setTimeout and document.FormName.Submit(); Eric
rekha vedali
Greenhorn
Joined: Sep 02, 2003
Posts: 5
posted
0
Could you please tell me how to display a timer in a JSP page, say having 1hr 30 min and have it count down to zero. Is there any predefined function in JavaScript or a tag in JSP or in HTML? Thanks, rekha
Thanks Eric for the link. I have written the �Countdown timer function� using JavaScript in JSP (using struts tags). I got a problem trying to open the application in the browser with tomcat . When I was trying to open with internet explorer or other browsers it is working fine without tomcat running. Does any one have any idea. If anyone has time to look at my code I will send it.