CGS4825 Assignment 3
Due Thursday, 3/16 at 6pm.
To hand in the assignment, zip your webapps directory and upload
it via the web:
Submitting
homework on-line via the Web.
-
Please use the following command to compress your webapps folder.
Change to your root directory on ocelot and issue the command
zip -r username cgs4825/webapps -x \*.jar \*.zip \*.war \*.gif \*.jpg access\* error\*
Replacing username with your user name.
-
If you have any other archived files in your directory, like .rar, or .ZIP,
or .WAR, please remove them before zipping.
-
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.
Do not modify your files on ocelot until after your assignment has been graded.
Stop your Apache servers. This assignment only uses Tomcat. By stopping the
Apache servers, ocelot will run faster.
In the webapps
directory
-
Create a directory named logs.
-
Give the directory 707 permission. Yes, I mean read, write and execute for
other.
-
Tomcat will place error messages in this directory if there is a problem
starting a web app, or running a servlet.
-
It may take 24 hours before Tomcat starts writing errors to this directory.
In the username/WEB-INF
directory
-
Create a directory named logs.
-
Give the directory 701 permission.
-
Create a file in the directory named log4jglobal.log.
-
Give the file 606 permission. Yes, I mean read and write to other.
-
When you use Log4J to write log messages, they will appear in this
file.
In the username
web application
-
Add the jar files to the lib directory of your username web
application for the Standard Template Library, Populating a Bean, and Logging
Servlets.
-
jstl.jar
-
standard.jar
-
log4j-1.2.11.jar
-
commons-collections-2.1.1.jar
-
commons-logging-1.0.4.jar
-
commons-beanutils.jar
-
These jar files must be added to your CLASSPATH on ocelot. I have written
a script that will modify the CLASSPATH.
-
Copy these jar files to the lib directory in your username
web application.
-
Each of these files is already on ocelot, in
~downeyt/cs/public_html/cgs4825/jar
.
-
Change to the lib directory of your web application and copy the files
into it. For example,
cp ~downeyt/cs/public_html/cgs4825/jar/*.jar ./
-
Make sure that the permissions are correct on these files.
-
Execute the following script once. Do not run this script again. This
script is only to be executed one time.
-
Be sure that the following command uses
>>
. If you only
use one >
then things will get all messed up.
~downeyt/public/bin/addJars.pl >> ~/.cshrc
-
Create a subdirectory of classes named utilities.
-
In the utilities directory, add the servlet for initializing a Log4J
logger. Be sure the package agrees with the location of the servlet.
-
Add a servlet definition and mapping for this servlet in the web.xml,
and set it so that the servlet will be run whenever the web application is
reloaded.
-
Create a subdirectory named hw3 in the root of this web application.
-
Map the controller servlet for this homework to this directory.
-
Add an cgs4825.jsp to this directory.
-
Include a hypertext link in the cgs4825.jsp file to the controller servlet
for this homework.
-
Include the Apache header and footer from HW2 in this file.
-
Copy the JSPs from HW2 into this directory and modify them as follows
-
The servlet will pass a collection of hidden field objects to the JSPs. Generate
the hidden fields in the JSP by looping through this collection. All HTML
should be in the JSP. No HTML should be in the servlet or bean.
-
Add a link in the cgs4825.jsp file in the root of the web application
to the hw3 directory .
-
Create a subdirectory of classes named hw3.
-
Create a bean in this directory that encapsulates the data from the JSPs.
-
Be sure that the package statement matches the location of the bean.
-
All hidden field data and methods should be in the bean. Generate a collection
of hidden field objects in the bean. There should be no HTML in the bean.
-
Add default validation in the bean for one of the text fields. Decide on
your own validation.
-
Be sure that your JSP indicates what a valid value should look like.
-
Examples of validation:
-
At least two words
-
A minimum length
-
A maximum length
-
One of several words
-
First letter capitalized
-
All digits
-
etc.
-
If the field fails validation, then choose a suitable default value.
-
Create a servlet controller.
-
Be sure that the package matches the location of the servlet.
-
Map the servlet to the hw3 directory in the root of the web application.
-
Every time the controller is accessed, create a bean object and populate
it from the request using the the populate method from the BeanUtils
class. If there are any errors during the population, be sure they are written
to the
/WEB-INF/logs/log4jglobal.log
file.
-
Add a statment that will write a comment to the
/WEB-INF/logs/log4jglobal.log
. You may write whatever you like.
I only want you to try using the log file, so that you can see that you can
use it to debug your code. Using the log file is similar to using
System.out.println
in a Java standalone application.
-
Make the bean available to the JSPs.