CGS4825 Assignment 5
Due Friday, 3/18 at 11:59 pm.
Create a new web app named hw5.
-
The simplest way to start this project is to copy the hw4 webapp to
hw5. Change to the webapps folder and issue these commands
umask 072
cp -r hw4 hw5
-
Copy the downey.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 add a path to the downey.jar file.
Remove the paths to the previous downey.jar files in the CLASSPATH variable.Did not serialize the rectangle class.
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 hw4 web app in hw5.
Make sure that everything works, and that the style sheet is being used in
all the correct places. If you hardcoded hw4 anyplace in your web
app, then you will need to change all those references to hw5.
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 hw5 web app.
-
Map your servlet to
/your-user-name.your-servlet
-
Create four links in the hw5/index.html file to this servlet
-
A link with no query string
-
A link with a query string that will send an email to the servlet
-
A link with a query string that will send an email and name to the servlet
-
A link with a query string that will send an email, name and title to the
servlet
-
Create a bean that corresponds to the form. Beans
-
Move replaceIfMissing and replaceIfMissingOrDefault into the
bean.
-
Modify getSize so that it has an int parameter, instead of
a string. It does not need to parse anymore. Return the default parameter
if the integer is 0.
-
Set default values in the setters.
-
In the getters for title, name and email, if
the variable is null, then return the empty string.
-
Create a BeanInfo class for the bean. Bean
Properties
-
Create an empty file for the database in the WEB-INF directory. Change
to the WEB-INF directory and issue these commands
touch hw5.db
chmod 606 hw5.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/hw5.db")
-
Use the getError method of the database to know if there are any errors.
-
SimpleDB Documentation
-
Create and populate the bean in doGet and doPost.
-
Move the HTML page that contains the form into the servlet.
-
Create a method to display the HTML page that contains the form.
-
Pass the bean to the method. Pass the PrintWriter to the method.
-
The form should use POST.
-
Prefill the name, title, and email, if they are in the
query string.
-
Modify the showPreview method.
-
Pass the bean, instead of the request, to the method.
-
Use the bean to create the preview.
-
Remove all the code that sets default values. Setting of default values should
now be in the setters of the bean.
-
Modify the makeStyleSheet method.
-
Pass the bean, instead of individual values, to the method.
-
Use the bean to create the stylesheet.
-
Modify the storeResume method.
-
Pass the bean, instead of the request, to the method.
-
Use the email as the key, and save the bean to the database. Use the
getError method of the database to know if there are any errors.
-
Modify the showConfirmation method.
-
Pass the bean to the method.
-
Display a table that has all the data that is in the database. Each row in
the database will have all the data for one of the resumes in the database.
Examples for you to look at
-
My example of
hw5
-
A servlet that moves the form into the servlet
-
A servlet that uses a database
-
A servlet that uses a BeanInfo class