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.