CGS4825, Assignment 4
Due Monday 11/3 at the start of class
You are to write a servlet for me. Upload a copy of your .java file
and hand in a printout. If you use additional .java files, then
zip all the files into one archive and upload the archive. Hand in
a printout of each .java file.
Write a servlet that will display a form containing the following. The form
should use POST. Choose a theme of your choice. All the input elements should
relate to your theme. Each of the following should be placed in a different
cell in a table.
-
A text box that will contain words.
-
A text box that will have an integer.
-
A text box that will contain a double.
-
A group of three radio buttons, all with the same name and different values.
-
A group of four check boxes, all with the same name and different values.
-
A selection list of several options, only one option may be selected
-
A selection list of serveral options, many of the options may be selected.
-
A submit button
When the servlet is called:
-
Use a common CSS for all the pages that the servlet generates.
-
If the browser will accept GZip encoding, then send compressed pages.
-
If the servlet is called via GET, then display an empty form.
-
Be sure to encode any input typed by the user so that data is not lost.
-
If the servlet is called via POST:
-
Verify the following
-
The text box for words should contain at least two words.
-
The integer should be between 1 and 12.
-
The double should be between 1.00 and 2.00.
-
One of the radio buttons must be selected
-
At least two of the options from the multiple selection list must be chosen,
but the user may not choose all of them.
-
If any of the validation conditions are not met, then
-
Redisplay the above form with a message listing which fields are invalid,
and why they are invalid.
-
For each invalid element, change the background color of its table cell.
Hint: use a different CSS style if the element is invalid.
-
Be sure that the user's previous valid choices do not have to be reentered
by the user if some of the fields are invalid.
-
If all the data is valid, then
-
Display a new page with all the user's choices listed in a well-formatted
text display. Do not display the data using form elements,
just display them as plain text (a table would be nice).
-
Add a form to the page with two buttons:
-
Edit. When pressed, redisplay the original form. Be sure that the
user's previous choices do not have to be reentered by the user. You will
need hidden elements to remember what the user's data is in order to redisplay
it.
-
Confirm. When pressed, display a thank you page that thanks the user
for filling out the form and that the data will be discarded, since we don't
know how to access a database yet.
-
Extra Credit (1 point): When a user has missing data, only redisplay the
form elements that need to be filled in. Your servlet must still remember
the elements that were filled in.