CGS4825 Assignment 2
Due Tuesday, 7/25 at 11:59pm.
To hand in the assignment, zip your cgs4825 directory and upload
it via ocelot: Submitting Homework from
Unix
-
Please use the following command to compress your cgs4825 folder.
Change to your root directory on ocelot and issue the command
zip -r username cgs4825 -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.
Modify .cshrc
Edit the file named .cshrc in your ~
directory.
Place these commands after the
# User additions go below here
#
#
and before any other CLASSPATH statements.
#
#Define the location of Java
#
setenv JAVA_HOME /depot/J2SE-1.5
#
#Define the location of Tomcat
#
setenv TOM_HOME /home/ocelot/aul-user-web/jakarta-tomcat-5.0.19
#
#Add directories and jars to the CLASSPATH
#
setenv CLASSPATH {$HOME}/cgs4825/webapps/ROOT/WEB-INF/classes
setenv CLASSPATH {$CLASSPATH}:{$TOM_HOME}/common/lib/servlet-api.jar
setenv CLASSPATH {$CLASSPATH}:{$HOME}/cgs4825/webapps/your-user-name/WEB-INF/classes
Replace your-user-name
with your user name. These commands will
allow you to compile java servlets on ocelot.
Configure Apache
-
Change the ServerName directive to your student host.
-
Configure Apache so that the following URLs are sent to Tomcat. No other
URLs should be sent to Tomcat.
-
All URLs that start with /manager/
-
All JSPs in the root of Tomcat
-
All URLS that start with /username/
-
Create a directory named hw in the document root and restrict access
to this directory in
access.conf
-
Only allow yourself and me to access your site.
-
Use my password file to check for valid users.
/aul/homes/downeyt/cs/etc/06s/registered.passwd
-
Create a default page for this directory that contains hypertext links to
the following.
-
The manger application on Tomcat, use a relative reference.
-
The default JSP in the document root of Tomcat, use a relative reference..
-
The username directory, use a relative reference.
-
Create a hypertext link in the default page of the document root of Apache
to the hw directory.
In the webapps
directory
-
Create a directory named logs.
-
Give the directory 707 permission. Yes, I mean read, write and execute for
other.
chmod 707 logs
-
Tomcat will place error messages in this directory if there is a problem
starting a web app or running a servlet.
-
It may take 3 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.
chmod 701 logs
-
Create a file in the directory named log4jglobal.log.
-
Give the file 606 permission. Yes, I mean read and write to
other.
chmod 606 log4jglobal.log
-
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.
-
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 hw2 in the root of the username web
application.
-
The controller servlet for this homework should be mapped to this directory.
-
Add a cgs4825.jsp to this directory.
-
Include a hypertext link in the cgs4825.jsp file to the Controller
servlet for this homework.
-
There will be no other files in this directory. The JSPs for this application
will be placed in the same physical directory as the Controller.
-
Add a link in the cgs4825.jsp file in the root of the username web
application to the hw2 directory in the username web application.
-
Create a controller application with a bean that behaves similarly to the
HW1 application.
-
Create a subdirectory of classes named hw2.
-
Create a bean in this directory that encapsulates the data from the JSPs
in HW1.
-
Be sure that the package statement matches the location of the bean.
-
Extend the bean from the BeanBase class.
-
Create a
doGet
method in the bean.
-
If there is a bean in the session, copy the session bean into the current
bean. Place the current bean in the session.
-
Populate the bean automatically. If there are any errors during the population,
be sure they are written to the
/WEB-INF/logs/log4jglobal.log
file.
-
Make the bean available to the JSPs.
-
Determine the address for the next JSP.
-
Forward the request and response to the next JSP.
-
Add default validation in the bean for one of the text fields.
-
Choose three or more valid options for the field, ignoring case. Be sure
that the user knows what the valid choices are.
-
If the user's data does not match one of thes options, then choose a suitable
default value.
-
Whenever the default value is chosen, write a detailed message to the log
file.
-
Create a servlet controller.
-
Be sure that the package matches the location of the servlet.
-
Every time the controller is accessed, create a bean object. Call the
doGet
method from the bean to handle the request.
-
Copy and modify the JSPs for HW1 into this directory.
-
The action statements should always call the Controller.
-
Remove the hidden fields.
-
Do not use ${param.xxxxxx} to access the request data; use the data from
the bean instead.
-
In the Edit page, be sure that the text elements are initialized with the
data from the bean.
-
Add a servlet definition and mapping for this servlet in the web.xml,
and map the Controller servlet to the hw2 directory in the root of
the username web application.