   	var backButtonPressed = 1;    
   	<!-- 0=no / 1=yes (assume per default that the back button will be pressed -->
   	<!--               and come into action if this was NOT the case)          -->


	function cancel() {
		backButtonPressed=0;
		forwardButtonPressed=0;
	 	document.form2.hiddenFieldName.name='cancelButton';
	 	<!-- activate cancelButton to pass its activation status to the servlet -->
	 	<!-- (the cancel button will be handled by the servlet) -->
		document.form2.submit();
	}

	function goBack() {
		if (backButtonPressed == 1) {
			backButtonWasPressed();
		}
	}
	function goForward() {
		if (forwardButtonPressed == 1) {
			forwardButtonWasPressed();
		}
	}	
	
	
	function backButtonWasPressed() {
		<!-- do whatever you want, e.g. call your implementation of the cancel button -->
		<!-- (which is not necessarily going back to the previous page) -->
		cancel();
	}
	function forwardButtonWasPressed() {
		<!-- do whatever you want, e.g. call your implementation of the cancel button -->
		<!-- (which is not necessarily going back to the previous page) -->
		cancel();
	}	