hi, I have a application made on servlets mainly,but i use xslt for display purpose.If any user make any entry in the application he can use the back button of browser to go to periovus page and redo the entry, i want to disable that, is there any whay i can disable the chache in browser.
i used the following line also. but not working // Set standard HTTP/1.1 no-cache headers. response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate");
Realistically, there is no way you can guarantee that a user will never resubmit an old form. Even if you disable the "back" button, there's usually a context menu option to go back, or the user can bookmark the form page and go back to the bookmark, or type in a "javascript" URL, etc. etc. A much more robust solution is to track on the server which forms have been submitted. Generate some sort of "transaction id", and pass it to the browser as a hidden form parameter. Then when the form is submitted, before it is procesed on the server, check on the server whether that id has already been received and dealt with. If you take this approach you can let the user be free to configure his/her own browser, and you can issue a friendly warning message if a form is submitted more than once.
Mr Frank, Could u show me an example or code on how to check the transaction id on server.I understood the concept but cannot understand how to implement it, Thanx, Felix
Hi felix My 2 cents.. If we go with suggestion brought up by Frank, then we would have to, - store all the submissions for a while for transaction id - also, it depends on what we choose as transaction id. for e.g. if we have chosen a user name that logged in then we have to make sure that we remove the transaction id from our "submitted requests" table as we want user to submit the form again in future. I hope I am able to convey my thoughts here. so in essence we can choose any mechanism for the transaction id but we have to make sure of certain things about managing it depending upon our application context/requirements.. Also, there are many disucussions about how to disable back button on Javaranch. So you can look for them if you wanted to dig into details about approaches/issues... Regards Maulin