Why my jsp page is submit twice?
I have two JSP page, there are one text and one button in index.jsp,when write some information in text area and press Enter Key,this page will be submit to other JSP page named cal.jsp,and in cal.jsp will print a message "receive".when I run this index.jsp,and write some information in textarea and then press Enter Key,I found this page is submit to cal.jsp,but I found that cal.jsp print two receive,like follows:
receive
receive
It should print "receive" once,but in fact it prints "receive" twice,why occur this condition? I only submit once.
My code is follows:
index.jsp
...
<script language="JavaScript">
<!--
function onCheck(){
if(strIsNull(document.thisform.code.value)==true){
alert("can't null");
return;
}
else{
document.thisform.action="cal.jsp";
document.thisform.submit();
}
}
function mykeydown() {
var whichkey=event.keyCode;
if (whichkey==13 || whichkey==10){
document.thisform.action="cal.jsp";
document.thisform.submit();
}
}
-->
</script>
<form form name="thisform" method="post">
<input name="code" type="text" size="18" onkeydown="mykeydown()">
<a href="javascript:onCheck();"><img src="images/queding.gif" width="46" height="19" border="0"></a>
</form>
...
cal.jsp
...
<%
System.out.println("receive");
%>
|