CGS4825 Assignment 4
Due Monday, 3/26 at 11:59 pm.
To hand in the assignment, zip your webapps directory and upload
it from ocelot.
-
Please use the following command to compress your webapps folder.
Change to your cgs4825 directory on ocelot and issue the command
zip -r username webapps -x \*.jar \*.zip \*.war \*.log
Replacing username with your user name.
-
Check the size of the ZIP file, it should be less than 1 MB. If it is not,
then you probably have another ZIP file stored in the ZIP archive. Delete
it and re-zip.
-
Use my uploading program from ocelot to upload the file.
~downeyt/cs/public/webftp/webftp.pl
-
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.
If you attempted HW3, but were unable to complete it, see me for help.
Adding JAR Files
For this assignment, you must add JAR files to your web application. You
may develop your assignment on ocelot or you may use NetBeans.
If you are developing on ocelot, then you need to copy the JAR files from
my directory to your lib directory.
-
Change to the lib directory of your web application.
-
Issue the command
cp ~downeyt/cs/public_html/cgs4825/jar/* ./
-
Modify the .cshrc file and include a CLASSPATH statement for each the log4j
and beanutils JAR files. The other JAR files are never accessed directly
by your code, so they do not need to be added to the CLASSPATH. Each command
should be on a separate line in .cshrc. Be sure that each entire command
is on one line.
setenv BOOKLIB {$HOME}/cgs4825/webapps/book/WEB-INF/lib
setenv CLASSPATH {$CLASSPATH}:{$BOOKLIB}/log4j-1.2.11.jar
setenv CLASSPATH {$CLASSPATH}:{$BOOKLIB}/commons-beanutils.jar
If you are developing on NetBeans,
-
Download the JAR files to your computer.
-
Open NetBeans and right-click on the project name in the Projects tab.
-
Select Properties.
-
Select Libraries.
-
Click the Add Jar/Folder button.
-
Navigate to the directory where the downloaded JAR files are.
-
Select all the JAR files you want to include in the web application.
-
After you have deployed the WAR file to ocelot, you will need to edit the
.cshrc file as is described above for ocelot.
Enhanced Controller
Implement the Enhanced application, from Chapter 4, on ocelot. Place it in
the book web application. Do not change the application in any way.
You are to get it working exactly as I have it working.
-
In addition to implementing the application as I have it, use the logger
to write some additional information messages to the log file.
-
Write an informational message every time the doGet method in the
controller helper is called.
-
Write an informational message every time the process button is clicked.
In the message, include the current value of the hobby from the bean.
-
If you are not using NetBeans and are developing solely on ocelot, do the
following to create the log file.
-
Create a subdirectory named logs in WEB-INF.
-
Create a file named error.log in logs.
-
Change the permission on error.log to 606
chmod 606 error.log
-
If you are developing locally in NetBeans, do the following to manage the
log file.
-
In the Web Pages folder, create a subdirectory named logs in WEB-INF.
-
Create a file named error.log in logs.
-
To view the errors in the error log:
-
Change from the Projects tab to the Files tab.
-
Open the build/web/WEB-INF/logs folder.
-
Open the error.log file. If the file is already open in NetBeans,
then close it and reopen it. NetBeans will not dynamically reread the contents
of the log file when it changes.
-
Note: The errors are written to the actual files that are built when the
application is run. The files in the Web Pages are copied to this directory,
but any changes made to the files at run time will not appear in the Web
Pages copy. This is why it is necessary to view the error log from the
Files tab instead of the Projects tab.
-
After deploying the WAR file to oceleot, it will be necessary to change the
permissions of the error.log file on ocelot.
-
On ocelot, change to the WEB-INF/logs folder.
-
Change the permission on error.log to 606
chmod 606 error.log
-
If this is not done, then Tomcat will not be able to write messages to the
log file when the app is run on ocelot.
-
In NetBeans, if you use Clean and Build Main Project from the Build
menu, then you will need to shut down Tomcat first.
-
Switch to the Runtime tab.
-
Open the Servers folder.
-
Right-click the bundled Tomcat server and select stop.
-
Note: When Clean and Build is selected, all the old files that were
created in the build directory are deleted and then recreated. NetBeans cannot
delete a file that is open. As long as Tomcat is running, the error log is
open. By stopping Tomcat, the error log will close and NetBeans will be able
to delete the log file.
Modify the Application
Now that the application is working, make the following modifications.
-
Move the JSPs to a different hidden directory.
-
Create a subdirectory of WEB-INF named ch4.
-
Create a subdirectory of ch4 named enhanced.
-
Move the JSPs from the directory of the controller to the
WEB-INF/ch4/enhanced directory.
-
Modify the controller so that it will access the JSPs from this new directory.
-
Add a new page to the application.
-
Add a page named WishList.jsp.
-
The whish list page will display the user's hobby and aversion,
but will not allow the user to edit it.
-
Add buttons to the wish list page that can send the user's data back to the
edit page or to the confirm page.
-
Add a button to the confirm page that can send the user's data to the wish
list page.
-
Modify the controller helper so that it incorporates the Wish List page.
-
Change the name that is used to store the helper in the session.
-
Use a name other than "helper" when calling
addHelperToSession
.
-
Modify the JSPs appropriately.