Another way to do this is to use a javascript function to store the current time in a hidden field. When the page is submitted, call the function, and then submit the page. Server Side, store the value in the session, and just check the incoming value to see if it is the same as the one stored in the session.
example:
//Client code:
function preventResubmit(){
//this function will insert the current time into the preventResubmit field
//the value will be stored in the session and a comparison will be made on subsequent actions to see if the time is the same
//in the case that it is, the user will be logged out
var theDate = new Date();
var milliDate = theDate.getTime();
document.formName.preventResubmit.value = millisDate;
}
<input type=hidden name=preventResubmit value="">
//Server code:
String sessionPreventResubmit = (String)session.getAttribute("preventResubmit");
String clientPreventResubmit = (String)request.getParameter("preventResubmit");
if(localPreventResubmit != null){
if(sessionPreventResubmit.equals(localPrev entResubmit)){
response.sendRedirect("error.htm");
}
else{
session.setAttribute("preventResubmi t", localPreventResubmit);
//jsp or servlet content here
}
}