CGS4825 Assignment 5
Due Tuesday, 6/10 at 6 am.
If you had any errors in Homework 4, then fix them, so that you don't lose
points twice for the same mistake.
Apache
Start your Apache server.
-
Create a subdirectory of
docRoot
named project
.
-
Add a subdirectory named
errors
in the project
directory.
-
Add an HTML page for 403 errors to this directory. This should be different
from the default HTML page and different from the one that you created for
Assignment 4.
-
Add an HTML page for 404 errors to this directory. This should be different
from the default HTML page and different from the one that you created for
Assignment 4.
-
Add a file named
cgs4825.html
to the project
directory.
-
Create a link to a file that does not exist.
-
Create a link to a file named
.htaccess
. Do not create this
file, just create a link to it. Apache does not allow access to such a file,
even if it doesn't exist.
-
Create a link to the
errors
folder.
-
Configure Apache for the
project
directory and its sub-directories.
These changes should not affect any other directories (like
docRoot
). Use access.conf
to implement these changes.
-
Limit access to you and me.
-
Set
cgs4825.html
as the default welcome page.
-
Set the error pages to the files in the
project/errors
directory.
-
Change the icon that is used for HTML files. Choose an icon that is
different from the default and different from the one that you used in Assignment
4.
-
Change the icon that is used for the parent directory. Choose an icon
that is different from the default and different from the one that you used
in Assignment 4.
-
Add the following to the
index.html
page in the
docRoot
folder.
-
Add a link to the
project
folder. The link should not include
a file name, it should be a link to the folder.
-
Remember to HUP your server after you make changes to the conf files.
Persistent Controller
Create a new package for this assignment in your username web app.
-
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 the application so that it implements the Persistent Controller from
Chapter 5. Review the steps in Tutorial 5.
-
Add all the necessary files to the
shared
package.
-
Note that
HellperBaseCh5
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.
-
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. There are additional annotations that can
be used with numeric properties.
Built-in
Annotations for Hibernate.
-
@Min(value=100)
-
@Max(value=200)
-
@Range(min=100,max=200)
-
Each of these needs an import statement:
import org.hibernate.validator.Min;
import org.hibernate.validator.Max;
import org.hibernate.validator.Range;
-
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.
-
Controller Helper
-
Use a unique name, other than "helper", to save the controller helper in
the session.
-
Modify
jspLocation
so that it returns the correct path for JSPs.
-
Write the current data to the database when the process button is clicked.
-
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.
-
Add a new page named
View.jsp
.
-
Display all the fields and all the data from the database.
-
In Tutorial 5, this infomation was displayed in the process page. For this
assignment, do not display that data in the process page, display it here
instead.
-
Add a button to this page that goes to the edit page. When the button is
clicked, a new transaction will be started: do not read the old data from
the session.
-
In the process page
-
Add a button to the process page for the view page.
-
The process page should display the current record that was just added to
the database, but should not display all the records from the database: that
information should be in the view page.
-
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 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 cgs4825/webapps/username folder.
zip -r username ~/cgs4825/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 cgs4825/serverRoot folder.
zip -r username ~/cgs4825/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 cgs4825/docRoot folder.
zip -r username ~/cgs4825/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/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.