This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes JSP and the fly likes Disabling refresh Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Disabling refresh" Watch "Disabling refresh" New topic

Disabling refresh

Bgg Singh

Joined: Mar 14, 2011
Posts: 4
i have developed an online exam system. when a user clicks on the "Start Test" button, the timer starts at the top of the page and questions are generated.

Now if the users refreshes the page, timer starts again and new set of questions come up (since of i have used random generation logic) .

i want users not to be able to refresh this page (disable refresh) so that timer should countdown till the end and for questions only one set of questions for one user be generated.

Any suggestions for this problem would be helpful.

Thanks in advance.
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 61092

You cannot successfully disable refresh in a cross-browser manner. And you shouldn't. See InterfaceDesignersRule1.

What you should do is to track the state of the exam and the timer in the session (most likely employing Ajax to send the state to the server periodically). That way, when the user refreshes, you can detect that they were in the middle of an exam, and restore the state at the time of the refresh.

[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
It is sorta covered in the JavaRanch Style Guide.
subject: Disabling refresh