Hi, I am working on a project that includes online examination and i am using Servlets.. and sessions. How do i prevent the user from using back button of the browser or is there any way of disabling the browser back button using servlets. It's very urgent requirement... Can i any one reply to it immediately... my e-mail id is email@example.com... Thanks... Bye...
Pounding at a thick stone wall won't move it, sometimes, you need to step back to see the way around.
I don't think you can disable the browser back - I would love to be able to. I think there are some settings in the response that prevent the browser from caching the data and expire it as soon as the user leaves a page - that would make it impossible to back up. On my list of things to work out.... Bill
It's the HttpServletResponse.setHeader(Stringname, String value) method. It sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one. The containsHeader method can be used to test for the presence of a header before setting its value. Parameters: name - the name of the header value - the header value
This method is then used in combination with the response headers Cache-Control: Expires:
Tony Alicea Senior Java Web Application Developer, SCPJ2, SCWCD
Joined: Aug 07, 2000
I think that it is not so much that you want to prevent the user from seeing the previous page, but that you really want to prevent them from re-posting an answer. This can be prevented by using nonces. A nonce is a unique id that you generate when you display your page. Typically it is put into a hidden form field. When the form is posted, you check to make sure that the nonce matches what was sent. You then invalidate that nonce so that if the form is posted again, you can reject the re-submission.
There is a j2ee pattern which deals with this stuff, the name is session token or something like that, sorry I cant remember the exact name, but you surely can find it if you look in the core j2ee patterns book, it is located in the extra stuff, not really a core pattern but a best practice as far as i remeber, the pattern just works fine i have used it in the past. Excellent book.
She will remember your heart when men are fairy tales in books written by rabbits.<br /> As long as there is duct tape... there is also hope.