This is a JavaScript question indeed, and definitely is not related to the server side.
Anyway, place a normal button, or a link, in your page to call a defined JavaScript function. For example:
<input type="button" onClick="submitForm()" />
or
<a href="javascript:submitForm()">SUBMIT</a>
I recommend the second one, since onClick and other mouse-related attributes make your code nonstandard. Define your function this way:
function submitForm() {
if (!submitted) {
document.forms[0].submit();
submitted = true;
}
}
"submitted" is a global variable, which must be set to "false" by default.
Your JSPs should only be a 'view'; only for displaying data.
All your database updating should take place in servlets.
You should look into asking the browser to not cache the page.
And since you're writing the code for the database entries, I don't think it'll be too difficult to verify that the data is not redundant. Primary keys anyone? :D
Use the disabled property, set it to true and then submit the form programmatically.
<html>
<head>
<script>
function validate()
{
var textfield = document.getElementById('textfield');
var submitButton = document.getElementById('submitbutton');
var mainForm = document.getElementById('mainform');
if ( textfield.value.length == 0 )
{
alert("Validation Failed");
return false;
}
submitButton.disabled = true;
alert("The button has been disabled, going to submit now");
mainform.submit();
}
</script>
</head>
<body>
<form id="mainform" action="#" method="GET">
<input type="text" value="" id="textfield"/>
<input type="submit" value="Try Me!" id="submitbutton" onclick="return validate();" />
</form>
</body>
</html>
A reminder though, this is JavaScript and these are Java forums.