Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Java > Java and JDK > Pro JSP
|
Pro JSP Advanced JSP coding questions. Beginning questions will be redirected to the Beginning JSP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro JSP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old November 5th, 2004, 04:33 AM
Authorized User
 
Join Date: Jul 2003
Posts: 62
Thanks: 0
Thanked 0 Times in 0 Posts
Default 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");
%>







Similar Threads
Thread Thread Starter Forum Replies Last Post
submit form and jump on previous page sanjeev jha Classic ASP Basics 0 November 3rd, 2007 06:18 AM
A single JSP page havin one submit & normal button PrincessDreamz JSP Basics 1 September 4th, 2007 07:08 AM
Blank Struts page after submit simistef Struts 2 August 28th, 2007 12:46 AM
How redirect to a new page after submit form... sevtov Beginning PHP 4 February 12th, 2007 06:49 AM
having two submit buttons in asp page and passing KGANESH2006 Classic ASP Basics 1 April 24th, 2006 09:58 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.