Restrict repeated submission of forms on the JSP client
There are two ways to restrict the repeated submission of forms on the client:
First, set a flag variable in a Javascript script to identify whether the form has been submitted. If yes, a dialog box is displayed, indicating "submit again ".
Type 2: After you click the submit button, set the submit button to the disabled status. In this way, you cannot submit the button again, and the client cannot submit the button again.
Use the first method: 1. Create a clienttest1.jsp file. The Code is as follows:
<% @ Page Language = "Java" C
Pageencoding = "gb2312" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" C>
<Title> restrict repeated submission on the client </title>
<Script language = "JavaScript"
<! -- Define repeated submission flag variables -->
VaR repeatsubmitflag = false;
<! -- Repeated submission check function -->
Function checksubmit ()
{
If (repeatsubmitflag) <! -- If the flag is true, the page has been submitted. -->
{
Window. Alert ('repeated submission is prohibited! ');
Return false;
}
Else
{
Repeatsubmitflag = true;
Return true;
}
}
</SCRIPT>
</Head>
<Body bcolor = "# ffffff">
<Form name = "form_client" Action = "http://www.dlmu.edu.cn">
<Input type = "checkbox" name = "check_1" Checked = true/> Dalian Maritime University
<Input type = "Submit" name = "submitok"/>
</Form>
</Body>
</Html>
2. If the form is submitted repeatedly, an error prompt dialog box will pop up.
The second method is used:
1. Create a clienttest2.jsp file. The Code is as follows:
<% @ Page Language = "Java" C
Pageencoding = "gb2312" %>
<! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
<Head>
<Meta http-equiv = "Content-Type" C>
<Title> repeated submission of client restrictions-2 </title>
</Head>
<Body bgcolor = "# ffffff">
<Form name = "form_client" Action = "http://www.dlmu.edu.cn"
>
<Input type = "checkbox" name = "check_1" Checked = "true"/> Dalian Maritime University
<Input type = "Submit" name = "submitok"/>
</Form>
</Body>
</Html>
2. If the form is submitted repeatedly, an error prompt dialog box will pop up.
This post from zdnetchina Chinese community http://bbs.zdnet.com.cn, this post address: http://bbs.zdnet.com.cn/viewthread.php? Tid = 93542