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 your Project.
Tasks
- Write a servlet that will accept the input from your Project 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
- When you test your code, make sure that you open your registration html file directly in your browser (not in NetBeans).
- If you are using FireFox, use the Live Http Headers plug-in to verify the accuracy of the data sent to and from your servlet.
- 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 bean.
- 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 generated page does not need to include any of the visual features of the project page (this is only an interim step).
- The e-mail validation can be very simple (e.g., check for the presence of a @ in the middle of the string.