CGS4854 Assignment for Chapters 6 and 7
Due Friday 11/30 (late 6am 12/1)
If you had any errors in the homework for Chapter 5, then fix them, so that
you don't lose points twice for the same mistake.
A summary of this assignment is
- Change the icons and errors for one folder in the file system.
- Continue to use the style sheet.
- Do not change the files for the last assignment. Make copies in new
folders and packages for this assignment.
- Give the bean a unique name, so you do not destroy data from previous
assignments.
- Add radio, checkbox and select elments that can be initialized and saved
along with all the other data.
- Add a login page to the application.
- Use cookies to identify previous users.
Apache
Make the following modifications for your Apache server.
- Create two new error message files in the errors folder for 403 and 404
errors. They should look different from the ones you created in the last
homework.
- Create a folder in
docRoot named private.
- Limit access to this directory to you and to me.
- Set the 403 and 404 error pages for the
private folder
and all its sub folders to the new error pages that you created. The
links for HW 4 should still see the old error pages.
- Change the icons for the
private folder for text and
html files.
- Use different icons from the default icons that are used in
Apache.
- Use different icons from the ones that you chose in HW 4.
- Only the icons for
private and all its sub folders
should change. If I look at the HW4 errors folder, I should still
see the icons that you chosse for HW 4.
- Create a subfolder named
examples.
- Add a text file to this folder. Include your name in the
file.
- Add an html file to this folder. Include your name in the
file.
- Create an index.html file in the
private folder.
- Add a link to a file that does not exist. Do not include any path
information in the href. There should only be the name of the
file.
- Add a link to a file that cannot be accessed. Do not include any
path information in the href. There should only be the name of the
file.
- Add a link to the
examples folder.
- Add a link in the docRoot/index.html to the private folder.
- Modify the style sheet.
- Change the default ordering that is used for
ol tags.
- Do not change the style for any
li tags.
- Do not create a named style.
- Choose one of upper-roman, lower-roman, upper-alpha, lower-alpha.
- Change the default ordering for nested
ol tags
(ol tags inside ol tags).
- Do not change the style for any
li tags.
- Do not create a named style.
- Choose one of upper-roman, lower-roman, upper-alpha, lower-alpha,
decimal (different from the ol ordering).
- Use the style sheet in all pages that can be accessed from Apache,
including all the files for your username web application on Tomcat (except
the manager).
Complex Persistent Controller
Create a new package for this assignment in your username web app. Step-bystep
instructions are available on the book's web site.
- Do not change the files that were used for assignment 4.
- Assignment 4 should still be accessible from the web app.
- You may copy files from assignment 4 into this new package.
- You may import files from assignment 4, if they are unchanged.
- Modify your application so that it can initialize and store complex form
elements. Review the steps in Tutorial 6.
- Add all the necessary files to the
shared package.
- Note that
HellperBaseCh6 should be placed in the
shared package.
- Add all the necessary JAR files to the Libraries folder.
- Bean
- Place the bean in the same package as the controller.
- Maintain all the properties that are already in the bean for your
project.
- Modify the property that could only match one of several
words.
- Use the mutator to store the string in lower case letters. For
instance, if one of the options is skiing and the user
enters Skiing, then store it as skiing.
- Be sure your program does not crash if the property is null or
the string is of length zero.
- You have a choice of new properties to add:
- You may add a radio group and a multiple
selection list.
- You may add a checkbox group and a single
selection list.
- If you want to add even more properties, you may; however, you
must implement at least the two that I have specified in the
choices above.
- Add annotations:
- Mark any properties that return arrays so that they can be saved
to the database in a separate table.
- Add annotations for radio groups, checkbox groups and select
lists so that they can be initialized easily in a JSP.
- The bean should implement required validation.
- The name of the class should be different than the name for the
bean in Tutorial 6 and Homework 4.
- Continue to implement all the validations from HW4.
- Validate that the radio group or single selection list has a
valid option.
- If the associated property in the bean is numeric, then use
min and max to validate the range of the value.
- If the associated property in the bean is a string, then user
a regular expression to validate it. Validate that it matches
one of the string values in the associated form element in the
JSP. You will also need to validate that it is not null (size 0
is not the same as null).
- Validate that at least two options from the checkbox group or
multiple selection list have been chosen.
- Look at the Hibernate
validations. There is one there that can help you.
- Remember that these types of elements are nullable: if
nothing is checked or selected, then there will be nothing in
the query string. You will also need to validate that it is not
null (size 0 is not the same as null).
- Controller Helper
- Use a unique name, other than "helper" and different from the name
used in HW4, to save the controller helper in the session.
- Modify
jspLocation so that it returns the correct path
for JSPs.
- Change the name of the accessor for the data to something other than
getData.
- Write the current data to the database when the process button is
clicked.
- Show all the records from the database in the view page. Use a name
other than database when placing the list of beans into the request.
- Treat GET requests as the start of a new transaction.
- Always show the edit page when a GET request is made.
- Do not read the old data from the session when a GET request is
made.
- Treat POST requests as the continuation of a transaction.
- Show the appropriate page based on the button that was clicked.
- Read the old data from the session and copy it into the bean.
- JSPs
- Use the Apache style sheet for all your JSPs.
- The JSPs should be in a hidden directory, but not in the same
directory as the controller. Move the JSPs to an appropriate
subdirectory of WEB-INF (not under classes).
- Edit page
- Use a table to organize the input elements so that they appear in
orderly columns. Place all the labels in one column and all the input
boxes in the second column.
- Be sure that your new input elements are initialized with the
values from the bean. This means that radio groups and check box
groups should be checked according to the values that are in the
bean; the same is true for selection lists.
- Display error messages for all properties that are not valid.
Use your style sheet so that the errors stand out on
the page.
- Confirm page
- Use nested ordered lists to display all the data in
the bean. Those elements that return arrays will use the inner
nested list to display all its values.
- Process page
- Use nested ordered list to display all the data in
the bean. Those elements that return arrays will use the inner
nested list to display all its values.
- Do not display all the data from the database on this page.
- There should be a button that allows the user to return to the
edit page and edit the data that was just entered into the
database, as well as a button for the view page.
- View page
- Use a table to display all the data from the database.
- The first row in the database should use a
th tag
for each column name.
- Use an unordered list to display those elements that have
multiple values.
- There should be a button that allows the user to return to the
edit page and enter new data into the database.
- Be sure there is a hypertext link in the
index.jsp page to
the controller. Use a relative link.
- The web app must use the secure web.xml file and should only allow
you and me to access your application: Edit tomcat users
- Be sure to modify the project so that the .java files are placed
in the WAR file: Configuring WAR File
- After the app is running in NetBeans, upload it and run it on ocelot: Uploading a WAR file
Login Cookie Controller
Add a login page to the application. Users must enter a valid panther id to access the site.
- If the user enters a valid panther id, try to read any information stored in the
bean for that panther id. If there is data, make it the data for the application.
- When new data is saved to the application, write a cookie, containing the panther id.
- When the application starts, if there is a cookie, read the data from the database
and skip the login page.
Extra Credit
Implement the wish list page.
- Add a field to the bean that indicates if the record is for the user's wish list.
- When the wish list button is clicked, save the data to the database with the
wish list property set.
- On the wish list page, display all the records for this panther id that have the
wish list property set.
Submitting the Assignment
Clean and Build your web application. After doing this, navigate to
the WAR file in NetBeans and verify that the .java files are included: View WAR
File
- Since you are using a log file that is in the web application, you will
need to shut down Tomcat before you can do a Clean and Build.
- Open the Services (Runtime in 5.5) folder and open the
Servers folder.
- Right-click the Tomcat server and select Stop.
- Now you can do a Clean and Build.
In the operating system (not in NetBeans) navigate to the dist folder in the
NetBeans project.
Deploy the WAR file on ocelot: Deploy a WAR File
- After deploying, open the
WEB-INF/logs directory in winscp
or on ocelot.
- Change the permission of the
error.log file to 606. This
will allow Tomcat to write to the file.
- Use the manager to stop your web application and then start it again.
This will force it to reread the
web.xml file so that the
logger can be initialized.
- Access your application and visit all the pages, then verify that some
new messages have been added to the log file.
To hand in the assignment, zip the following directories into one ZIP file
and upload it.
- Please delete your old ZIP file that you used to submit
homework.
rm username.zip
Replacing username with your user name.
- Please zip the following. Issue a separate ZIP command for each. All
the files will be added to the same ZIP file.
- Please use the following command to compress your
cgs4854/webapps/username folder.
zip -r username ~/cgs4854/webapps/username -x \*.jar \*.zip
\*.jpg \*.gif \*.war
Replacing username with your user name. This will create a file
named username.zip. It contains the username web application.
- Please use the following command to compress your
cgs4854/serverRoot folder.
zip -r username ~/cgs4854/serverRoot -x \*.jar \*.zip
\*.war
Replacing username with your user name. This will create a file
named username.zip. It contains the username web application.
- Please use the following command to compress your
cgs4854/docRoot folder.
zip -r username ~/cgs4854/docRoot -x \*.jar \*.zip
\*.war
Replacing username with your user name. This will create a file
named username.zip. It contains the username web application.
- Check the size of the ZIP file, it should be less than 3 MB. If it is
not, then you probably have another ZIP file stored in the ZIP archive.
Delete it and re-zip.
- You then have a choice for submitting the file.
- If you are logged onto ocelot, use my uploading program to upload the
file. Enter this command at the command prompt:
~downeyt/public/webftp/webftp.pl
- If you are using winscp, then download the zip file to your computer;
then, upload the file to me: Submitting
homework on-line via the Web.
- Upload the file as binary.
Be sure that all your files and subdirectories are included in the zip
file.
After uploading, do not modify your files on ocelot until after your assignment
has been graded.