• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

timer in jsp

 
santosh mohanty
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Stevens
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to JSP forum.
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 136
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 65120
91
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Moving to the HTML/Javascript forum.
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Look Here
 
rekha vedali
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

Thanks,
Rekha
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic