Java Web basics: 12th use of Form Elements

Source: Internet
Author: User
This article is excerpted from: Java Web development tutorial-getting started and improving (JSP + servlet). This article introduces the basic syntax of form elements on pages 50th and 51. Encapsulate the information to be submitted using the form ElementTo submit information to the server, you must use the form element. All information to be submitted should be in the form. On the registration page, all information to be entered is inside the form element. The basic format of form elements is as follows: <form name = "form1" Action = "target file" method = "post | get"> various form elements </form> start with "<form> ", the end flag is "</form>", and various form elements used to submit information are in the middle. In the start flag, the name attribute indicates the form name, and the action indicates the file to be submitted for processing. The name of the file to be processed should be written. If the action value is a null string, the method attribute specifies the form submission method. There are two optional methods: Post and get, usually post. Note: the start and end signs of a form must not be less, and all form elements used to submit information should be within the form element. Multiple forms on the same pageYou can have multiple forms on the same page, for example, the following format: <form name = "form1" Action = "target file" method = "post | get"> form elements in the first form </form>... <form name = "form2" Action = "target file 2" method = "post | get"> form elements in the second form </form> if multiple forms exist, what information will be submitted when information is submitted, and what file will be submitted for processing? This is related to the position of the submit button. If the submit button is in the first form, the second form will not work at this time. Only the value of the form Element in the first form will be submitted, and the file specified by the Action attribute submitted to the first form is processed by this file. Multiple forms do not affect each other. In which form the submit button is located, only the values of the form elements in the form are submitted, only the processing file specified by the Action attribute of the form will be submitted for processing. A page can contain multiple form elements to complete different information submission tasks. However, multiple form elements cannot be nested. For example, the following structure is a nested structure, which is incorrect. <Form name = "form1" Action = "target file" method = "post | get"> form elements in the first form... <form name = "form2" Action = "target file 2" method = "post | get"> form elements in the second form </form> Instance<Form name = "form1" Action = "register_confirm.jsp" method = "Post" onsubmit = "Return isvalidate (form1)">... </Form> Last Lecture: Lecture 2 Basic form elementsNext Lecture: 13th client VerificationLi xucheng csdn blog: Why? U= 124362 & C = 7be8ba2b6f3b6cc5

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.