• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

timer in jsp

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2823
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to JSP forum.
 
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 136
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 67750
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moving to the HTML/Javascript forum.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Look Here
 
rekha vedali
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Tick check! Okay, I guess that was just an itch. Oh wait! Just a tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic