CGS4825 Assignment 4
Due Tuesday, 11/14 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 JAR that
is in the lib directory of your web application. An example follows for
log4j. This command should all be on one line in .cshrc.
setenv CLASSPATH
{$CLASSPATH}:$HOME/cgs4825/webapps/book/WEB-INF/lib/log4j-1.2.11.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 and include a CLASSPATH statement for each JAR that is in the
lib directory of your web application. An example follows for log4j.
This command should all be on one line in .cshrc.
setenv CLASSPATH
{$CLASSPATH}:$HOME/cgs4825/webapps/book/WEB-INF/lib/log4j-1.2.11.jar
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.
Apache
If you have not done so, be sure that Apache forwards all URLs that start
with /book/
to your Tomcat web application named book.
Web Applications
For the book web application:
-
Be sure that cgs4825.jsp is the default welcome page for a directory in the
book web application.
-
Be sure that a custom error message appears when a requested resource is
not available.
-
Add a link to the cgs4825.jsp file in the book directory to the enhanced
controller.
For the ROOT web application:
-
Be sure that cgs4825.jsp is the default welcome page for a directory in the
ROOT web application.
-
Be sure that a custom error message appears when a requested resource is
not available.
-
Add a link in the cgs4825.jsp in the ROOT web app to the root of book web
app.