Assignment # 3
Learning Goals
- Understand how to pass form data from an html page to a servlet.
- Understand how to create a Java Bean.
- Understand how to populate a Java Bean with data from the form dataset.
Project
This assignment is part of Project#1.
Tasks
- Write a servlet that will accept the input from your Project 1 form.
- Modify the HTML page for your project so that the form submits to your servlet.
- Create a Java Bean that will hold the values of the form elements in your form.
- Include the code in your servlet to populate the bean.
- Add an isValid method to your bean that will perform the following validation:
- All required fields contain data (a required field is denoted with a * in the page).
- The e-mail field is in the correct format for an e-mail address.
- Invoke the isValid method from your servlet, and display information in your generated html that states the validity of the input data.
Identify each field that contains an error.
Hints
- You might include a validation method in the bean for each field whose value you check. The isValid method (also in the bean) might call
each of these individual validation methods.
- The bean will be used later in your project when you need to repopulate the JSP form with the data in the beam.
- You can display the data validity messages in a simple html page generated by the servlet (later you will add the validity messages to the
regenerated form).
- The e-mail validation can be very simple (e.g., check for the presence of a @ in the middle of the string.