I think your are submitting the page twice like : a)onCheck() : On check submits the page once. b) mykeydown(): when you press enter(whichkey==13 ) also submits the page.
Regards Amar -----Original Message----- From: A mailing list about Java Server Pages specification and reference [mailto:[EMAIL PROTECTED] Behalf Of Edward King Sent: Friday, November 05, 2004 1:57 PM To: [EMAIL PROTECTED] Subject: 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"); %> Any idea will be appreciated! Best regards, Edward =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com =========================================================================== To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST". For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST". Some relevant archives, FAQs and Forums on JSPs can be found at: http://java.sun.com/products/jsp http://archives.java.sun.com/jsp-interest.html http://forums.java.sun.com http://www.jspinsider.com