CGS4854 Assignment 5
Due Thursday, 11/13 at 1pm.
If you had any errors in Homework 4, then fix them, so that you don't lose
points twice for the same mistake.
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.
-
Remove any default validation for this field.
-
@Min(value=100). Do not use the Hibernate annotation, use mine. Add the following
files to the shared package:
Min.java,
MinValidator.java.
-
@Max(value=200). Do not use the Hibernate annotation, use mine. Add the following
files to the shared package:
Max.java,
MaxValidator.java.
-
@Range(min=100,max=200). This is a built-in annotation for Hibernate:
Built-in
Annotations for Hibernate.
-
Each of these needs an import statement:
import shared.Min;
import shared.Max;
import org.hibernate.validator.Range;
-
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.
-
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.
-
Use a name other than "database" to store the database records in the request.
-
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.
-
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
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.
-
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.