CGS4854 Homework 3
Due Tuesday, 11/19 (late 11/20 at 6am)
If you had any errors in the previous homework, then fix them, so that you
don't lose points twice for the same mistake.
Apache
Start your Apache server.
- Modify the style sheet from previous assignment.
- Limit access to the
styles
directory to you and to me. Limit access before you create your
style sheet. I do not want anyone but you and me to be able to see your style sheet at any time.
- Change the default style for the entire page.
- Change the color of the text.
- Change the color of the background.
- Change the font-family. Use at least three possible fonts; the
last font in the list should be a generic font family. Do not
include more than one generic font family in the list.
- Change the default styles for
h1
tags.
h1
headings should use a
different font than the body. Use the font-family attribute and
specify a very specific font, a more common font and a generic
font. All of these must be different from the default fonts for the
page.
- Change the background image.
- Be sure the text color contrasts with the background
image.
- Change the default style for unvisited hypertext links.
- Change the text color.
- Change the background-color.
- Make the font smaller than the body font. Use a relative
measurement.
- Change the default style for visited hypertext links.
- Change the text color.
- Change the background-color.
- Visited links will automatically inherit the font-size that is set for unvisited links.
- 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).
- Modify the
docRoot/index.html
file.
- Add a heading.
- Create one
h1
heading at the top of the page.
- Do not use a heading for an entire paragraph.
- A heading should contain just a few words.
- Modify the error pages.
- Add a heading to each error page.
- Create one
h1
heading at the top of each error page.
- Do not use a heading for an entire paragraph.
- A heading should contain just a few words.
- Include the number for the error in the heading.
Persistent Controller
Create a new package for this assignment in your username web app.
- Do not change the files that were used for the previous assignment.
- All assignments should still be accessible from the web app.
- You may copy files from previous assignments into this new package.
- You may import files from previous assignments, if they are
unchanged.
- Modify the application so that it implements the Persistent Controller
from Chapter 5. It should also implement the Post Controller and Required
Validation. Review the steps in Tutorial 5.
- Add all the necessary files to the
shared
package.
- Note that
HelperBaseCh5
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.
- Use a new name for the bean class, so it does not overwrite the bean
from the extra credit.
- Add annotations so that the bean can be saved to a database.
- Annotate the class so that it can be saved to its own table.
- Add a key field to the bean or extend it from
PersistentBase
.
- Mark any properties that only have accessors so that they are not
saved to the database.
- The bean should implement required validation.
- Validate that one of the numeric fields is in a specific range of
numbers.
- Do not include 0 in the range.
- Include an upper and lower
bound for the range of numbers.
- Remove any default validation for this field.
- Use the Pattern annotation to validate that one of the string
properties only contains one of several words.
- Choose at least three words.
- The match should not be case sensitive.
- For each field that is to be validated, display information in
the web page that indicates the correct format of the data to be
entered.
- For all the other fields, you must implement either
required validation or default validation.
- Controller Helper
- Use a unique name, other than "helper" and different than the one for
Tutorial 5, to save the controller helper in the session.
- Change the name of the accessor for the bean to something other than
getData
.
- Modify
jspLocation
so that it returns the correct path
for JSPs.
- Write the current record to the database when the process button is
clicked.
- Do not retrieve records in this method.
- Write an information message to the log file containing the id of
the record that is being written to the database.
- Add a button method for the view page (described below). Read the
records from the database and make them available in the request for
next JSP.
- Do not save to the database in this method.
- Write a debug message to the log file that contains the number of
records that were retrieved from the database.
- Write a warning message to the log file if no records were
retrieved from the database.
- Use a name other than "database" to store the database records in the
request.
- When you are debugging your application, set the log level to debug.
When you submit the assignment, change the log level to error.
- JSPs
- There should be no hidden fields in any of the 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).
- Modify all the EL statements so that they refer to the new name that
you used to store the helper in the session and the new name you used
for the bean accessor.
- Add a heading to each JSP. Use the
h1
tag.
- Modify
Edit.jsp
- Use a table to organize the input elements so that they appear in
orderly columns. Place all the labels in the first column and all the input
boxes in the second column.
- Display error messages for all properties that are not valid.
- Modify the confirm page.
- Use an ordered list to display all the data in
the bean.
- Modify
Process.jsp
.
- Only display the current record from the bean.
- Do not display all the records from the database in this page.
- If you do not have one, add a button that returns to the edit
page so the user can change the values that were just saved. When
the edit page appears, the current values should appear in the
input elements in the page.
- If you do not have one, add a button that returns to the edit
page to start a new request. When the edit page appears, the current
values should NOT appear in the input elements.
- Add a button that sends the user to the view page.
- Add a new page named
View.jsp
.
- 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.
- Add a button that returns to the edit page so the user can change
the values that were just saved. When the edit page appears, the
current values should appear in the input elements in the page.
- Add a button that returns to the edit page to start a new request.
When the edit page appears, the current values should NOT
appear in the input elements.
- 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
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 use the following command to compress your
cgs4854/webapps/username folder.
zip -r ~/username ~/cgs4854/webapps/username -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/serverRoot folder.
zip -r ~/username ~/cgs4854/serverRoot -x \*.jar \*.zip
\*.war
Replacing username with your user name. This will add the
serverRoot folder to username.zip.
- 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 add the
docRoot folder to username.zip.
- 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/cs/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.