The form-related tags consist of the <form> tag itself plus all tags that must be used inside it. For example, the <text> and <password> tags are form-related tags because it does not make sense if they are not placed inside a form.
The <form> Tag
The <form> tag generates an HTML form. You must follow a number of rules to use this tag.
First and foremost, a <form> tag must contain an action attribute, the only required attribute for this tag. Without an action attribute, your
JSP page will throw an exception. Then, you must assign a valid value to this action attribute. A valid value is the path in any of the <action> elements in the <action-mappings> element in the application's
Struts configuration file. Also, the corresponding <action> element must have a name attribute whose value is the name of a form bean.
For example, if you have this <form> tag:
<html:form action="/login" >
the <action-mappings> element of your Struts configuration file must have this <action> element in bold:
<action-mappings>
<action path="/login"
type="com.javapro.struts.LoginAction"
name="loginForm"
scope="request"
input="/login.jsp">
<forward name="success" path="/mainMenu.jsp"/>
</action>
.
.
.
</action-mappings>
This is to say that a form tag is associated with a form bean.
Another rule to follow: Any tag contained within the <form> tag to receive user input (<text>, <password>, <hidden>, <textarea>, <radio>, <checkbox>, <select>
must have its property value assigned to a property in the associated form bean. For instance, if you have a <text> tag whose property is assigned the value "userName", the associated form bean must also have a property called "userName". The value entered into this <text> tag will then be used to populate the userName property of the form bean.