CGS4825 Assignment 6
Due Monday, 4/4 at 11:59 pm.
Create a new web app named hw6.
-
The simplest way to start this project is to copy the hw5 webapp to
hw6. Change to the webapps folder and issue these commands
umask 072
cp -r hw5 hw6
-
Copy the downey.jar file into the
lib directory of this web app.
-
Copy the coreservlets.jar file
into the lib directory of this web app.
-
Edit the .cshrc file on ocelot, and add a path to the classes
directory of this web app. Also paths to the downey.jar and
corservlets.jar file. Then run the command
source ~/.cshrc
-
Once you have created the web app structure, add the web app to your
host using your manager.
-
You should now have an exact copy of the hw5 web app in hw6.
Make sure that everything works, and that the style sheet is being used in
all the correct places. If you hardcoded hw5 anyplace in your web
app, then you will need to change all those references to hw6.
Modify the web app as follows.
-
Create a link in the ROOT/index.html to the root of this context.
-
Create a new mapping for sevlet to the root of the hw6 web app.
-
Map your servlet to
/your-user-name.your-servlet
-
Create several links in the hw6/index.html file to this servlet
-
A link with no query string
-
A link with a query string that will send an email that is in the database
-
A link with a query string that will send an email that is not in the database
-
Modify the style sheet in the styles directory
-
Add an error class that will invert the default foreground and background
colors of the page.
-
Add the following methods to the bean.
-
isEmailValid
- This will return a boolean value that tests if
the email is not null, and contains exactly one @
sign.
-
getEmailError
- This will return the empty string or an error
message, depending on whether the email is valid.
-
Create an empty file for the database in the WEB-INF directory. Change
to the WEB-INF directory and issue these commands
touch hw6.db
chmod 606 hw6.db
-
Construct the database in the init method of the servlet.
-
Pass the following to the constructor to identify the path to the database
getServletContext().getRealPath("/WEB-INF/hw6.db")
-
Use the getError method of the database to know if there are any errors.
-
Do not display a table of all the data on the Confirmation page.
-
Create a cookie
-
Create a cookie when the confirmation page is displayed.
-
The cookie should contain the email address on the resume.
-
The cookie should expire after one minute.
-
Modify the method that displays the form so that all elements can be prefilled
(Sticky Forms). Be sure that your bean extends
my
PresetCheckedAndSelected
class.
-
For a
GET
request
-
If there is a query string, then check if there is an email address
-
If there is, then test if the email address is in the hw6 database
-
If it is, then display the Form page with all of the resume data filled in.
-
If there is not an email, or the database returns null, then populate
the bean normally and display the Form page.
-
If there is no query string, then test if there is a cookie that contains
the email
-
If there is, then test if the email address is in the hw6 database
-
If it is, then display the Form page with all of the resume data filled in.
-
Add the following buttons to the application. In order for buttons to work,
they must be in a form.
-
Add an Edit button to the Preview page. Pressing this button will bring up
the Form page with all the user's data filled in.
-
Add a Submit button to the Preview page. Pressing this button will submit
the user's resume and bring up the Confirmation page.
-
Add an Edit button to the Submit page. Pressing this button will bring up
the Form page with all the user's data filled in.
-
Add a Preview button to the Submit page. Pressing this button will bring
up the Preview page with all the user's data filled in.
-
Give the buttons unique names so the servlet can deterimine which was the
last page.
-
In
doPost
, use a nested if ... else if ... else
block to test which button was pressed.
-
Only access the hw6 database
-
From a
GET
request when there is no query string and there is
a cookie containing an email.
-
When the resume data is being saved just before the Confirmation page is
to be displayed.
-
Use the session database
-
To save the bean after leaving the Form page.
-
To read the bean after leaving the Preview or Confirmation pages.
-
When the user presses Submit or Preview from the Form page
-
Validate that the email is not empty and contains exactly one
@
sign.
-
If the email is not valid
-
Redisplay the Form page
-
Display an error message above all the form elements. Use your error class
to make it apparent.
-
Use the your error class to change the colors for the
DD
element
that contains the email element.
My example of
hw6