JSP processing method for duplicate submission of form _jsp programming

Source: Internet
Author: User
Tags key string

The examples in this article describe how JSP handles recurring forms for form submissions. Share to everyone for your reference, specific as follows:

1. When you generate the form, you do the following:

Copy Code code as follows:
Session.setattribute ("Forum_add", "Forum_add");

2. When submitting the processing, make the following judgment

if (Isredo (Request, "Forum_add")) {
 //prompt for repeated submissions, for related processing
}

Related functions:

/**
* To determine if the repeat submission
* 1, check whether the session contains the specified name of the property
* 2, if the session does not have the attribute or the attribute is empty, the proof has been processed, to judge the duplicate submission
* 3, otherwise, The proof is first processed and the attribute is removed from the session.
* @param key String
*
/private Boolean Isredo (HttpServletRequest request, string key) {
  string Value = (String) request.getsession (). getattribute (key);
  if (value = = null) {return
   true;
  }
  else {
   request.getsession (). removeattribute (key);
   return false;
  }
}

I hope this article will help you with JSP program design.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.