Create an HTML page with a Form validation using JSP. An HTML file and a JSP fil
ID: 3667632 • Letter: C
Question
Create an HTML page with a Form validation using JSP.
An HTML file and a JSP file is required.
The fields have the following properties:
- user first name (text)
- user last name (text)
- user username (text- no more than 10 character with validation)
- user password (password - at least 6 characters with validation)
- user retyped password (password)
- user address (text)
- user email (text – with validation)
- clear form button and a submit button
Functionality: when you press submit the form is validated for empty field.
Explanation / Answer
The following sections describe how to use WebLogic JSP form validation tags:Creating HTML Forms Using the <wl:form> Tag. The name attribute is requiredwhen using multiple forms on a page.Copy the weblogic-vtags.jar file from the ext directory of your WebLogic Server installation into the WEB-INF/lib directory.
To use a validation tag in a JSP:
Write the JSP.
Enter a taglib directive to reference the tag library containing the WebLogic JSP Form Validation Tags. For example:
Note that the prefix attribute defines the prefix used to reference all tags in your JSP page. Although you may set the prefix to any value you like, the tags referred to in this document use the wl prefix.
Enter the <wl:summary> ... </wl:summary> tags.
Place the opening <wl:summary ...> tag before any HTML code, JSP tag, scriptlet, or expression on the page.
Place the closing </wl:summary> tag anywhere after the </wl:form> tag(s).
Define an HTML form using the <wl:form> JSP tag that is included with the supplied tag library. For more information, see <wl:form> and Creating HTML Forms Using the <wl:form> Tag. Be sure to close the form block with the </wl:form> tag. You can create multiple forms on a page if you uniquely define the name attribute of the <wl:form> tag for each form.
Create the HTML form fields using the HTML <input> tag.
Add <wl:validator> tags. For the syntax of the tags, see <wl:validator>. Place <wl:validator> tags on the page where you want the error message or image to appear. If you use multiple forms on the same page, place the <wl:validator> tag inside the <wl:form> block containing the form fields you want to validate.
The following example shows a validation for a required field:
If the user fails to enter a value in field_1, the page is redisplayed, showing a warning.gif image, followed by the text (in red) "Field 1 is a required field," followed by the blank field for the user to re-enter the value.
Copy the weblogic-vtags.jar file from the ext directory of your WebLogic Server installation into the WEB-INF/lib directory of your Web Application. You may need to create this directory.
Configure your Web Application to use the tag library by adding a taglib element to the web.xml deployment descriptor for the Web Application. For example:
Example of a User-written Validator Class :
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.