CGS4825, Assignment 6
Due Friday 12/5 at midnight
You are to create a project that has one servlet and several JSPs. Create
a JAR file and upload it.
Use POST when submitting the data from the browser to the server.
Add a link to your server's default page that links to this servlet.
-
You should place .class files in your classes directory for your web
app on Otter and run them from the path
/cgs4825_your-user-name/servlet/MyServlet
-
You should be able to place .jsp files in the java-servlets directory and
run them from the path
/cgs4825_your-user-name/MyJSP.jsp
-
In general, you should give directories 705 permissions and files 604
permissions. There is one exception: the directory where you will be storing
your database file. In order to create the database the first time, the directory
will need 707 permissions. After you run your servlet once, you can go back
and change the permissions to 705. 707 is a very dangerous permission!
-
The path name that you use in Java to construct the simple database must
be the full path name: /aul/homes/........
-
You can use a .jar file to upload your work from your PC to otter.
I suggest you just unpack it on the server with
jar -xvf file.jar
.
There will be several different JSP pages displayed by this project.
-
The Login Page.
-
The Form Page. If this page is loaded in repsonse to the submit button
from the Login Page and the Phone Number is in the database,
then fill in the form elements with the data from the database. If this page
is loaded in response to any other form button, then be sure that
the form elements are filled in with the previous values (make it sticky).
-
The Confirmation page. This page displays all the information that
the user has submitted, but as plain text, not in HTML form elements. Arrange
the data in a nice HTML table.
-
Each page should include a header and a footer. These files should be in
the
/cgs4825_your-user-name/includes
directory of your
server. The header should contain some information about the servlet that
you are creating. The footer should contain some information about your website.
Each page will display the same header and footer. Remember that when you
use the <jsp:include>
directive, paths that start with
a / are relative to the web app root, not the document root.
-
Use the same style sheet to control the look of each page. Use an HTML
<Link> tag to control this. Remember that this is a HTML statment,
so that paths start with a / are relative to the document
root.
<LINK REL="STYLESHEET" TYPE="text/css"
HREF="location-of-style-sheet">
The Login Page will display a form with a Submit button and
a text box for the Phone Number, and a text box for an E-mail
Address.
-
The Phone Number should be "sticky".
-
The Phone Number cannot be blank.
-
Validate that the Phone Number is in one of these formats:
999-999-9999; 999 999 9999; 999.999.9999; 999999999.
-
You might find these links helpful for checking that the phone number is
in one of these formats
-
If the Phone Number is invalid, then redisplay the Login Page
with an appropriate error messages.
-
If the Phone Number is valid, then initialize the Form Page
as follows
-
If the Phone Number is already in the database, then fill in the Form
Page with the user's data from the database. Note: the database is read
only when the Form Page is called in response to the button on the
Login Page.
-
If the Phone Number is not in the database, then all the form elements
in the Form Page should be empty.
The Form Page will have the following.
-
The form should be sticky.
-
Display the Phone Number on the page as plain text (do not display
it in a form element). Display it in the format (999) 999-9999, regardless
of how the user entered it.
-
The form will contain the following elements. Arrange them in an HTML table:
place the text describing the element and the element itself in separate
<TD> tags.
-
A text box.
-
A radio group with at least four options.
-
A multiple selection drop down list with at least five options.
-
Add some text that identifies each element.
-
A Submit button. When this information is submitted, the script should
verify that
-
The text box contains at least two words.
-
The radio group has been selected.
-
Between 2 and 4 selections have been chosen from the selection list.
-
If there are invalid fields, then redisplay the Form Page with
all appropriate error messages. If there are multiple errors, then
display all the errors. Change the background color of each <TD> element
that contains an invalid field. Use your stylesheet to control the color.
Be sure that the form is sticky.
-
If all the fields are valid, then display the Confirmation Page.
The Confirmation Page will have the following:
-
Display the user's information as plain text (do not display them in form
elements.)
-
Display the following buttons in a form:
-
Edit: if clicked, then the Form Page is redisplayed, with all
of the user's information filled into the form. Use the information from
the Confirmation Page, not the information in the database. The Phone
Number should still be displayed as plain text in the Form Page.
-
Confirm: if clicked, then write the user's information to a
database. Do not write to the database until this button is clicked.
Use the Phone Number as the key field. Redisplay the Confirmation
Page with with an extra message indicating that the data has been entered
into the database.
-
New User: if clicked, then display an empty Login Page.
Please note that the data is not entered into the database until the
user presses Confirm on the Confirmation Page.
I have created a simple database for you to use:
SimpleDB.java
Javadocs for SimpleDB
Grading Policy
-
10 points. Be sure that you can access each page without using any validation.
Place all HTML in JSPs. Place all validation and logic for calling a page
in the servlet.
-
1 point. Header and Footer for each page.
-
1 point. Same style sheet for each page.
-
2 points. Update the database.
-
2 points. Simple validations: non-empty text boxes and radio groups.
-
1 point. Validate phone number has specific format.
-
1 point. Validate that 2 to 4 items have been selected.
-
2 points. Create list of all errors, change background color of TD elements
with errors.