CGS4825 Assignment 2
Due Friday, 10/7 at 11:59 pm.
To hand in the assignment, zip your webapps directory and upload
it via the web:
Submitting
homework on-line via the Web.
Be sure that all your files and subdirectories are included in the zip
file.
Do not modify your files on ocelot until after your assignment has been graded.
Your are to create a new web application on ocelot. The name of the web app
should be your user name. Use the secure web.xml file for this
application.
After creating the new web application, open the manager application for
your host. In the Deploy section, enter the name of the web application
in the WAR or Directory URL: text box and click the Deploy
button. If all went well, then you will see that your new web appication
is running. If it is not running, then check that you have no errors in your
web.xml file.
Edit the file named .cshrc in your ~
directory. Add the
following commands to the end of the file
#
#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
These commands will allow you to compile java servlets on ocelot.
Modify index.html in the ROOT directory so that it has a link to the root
of your new web application.
Create a subdirectory named hw2 in the root of the new web application.
-
Map the controller servlet for this homework to this directory.
-
Add an index.html to this directory. Include a hypertext link to the controller
servlet for this homework.
Add an index.html to the root of your new web application. Include a link
to the hw2 directory.
Create a subdiretory of WEB-INF named hw2_JSP. Create three JSPs in this
directory
-
Edit.jsp This page will be similar to the first page that was created
in HW2. This time, use a theme that does not include name, address, or email.
-
Confirm.jsp This page will display the data that was sent to it. Also,
it will have hiddden fields and two buttons for sending the data to the Edit
or Process pages.
-
Process.jsp This page will display the data that was sent to it. Also,
it will have hidden fields and a button for sending the data to the Edit
page.
-
Each page that needs hidden fields will display an attribute that contains
the HTML for the hidden fields. This attribute will be sent from the controller.
-
Each page will display an attribute that contains your name. This attribute
will be sent from the controller.
-
Each page will display an attribute that contains the following oath. The
attribute will be sent from the controller.
I attest that the homework I am uploading was done by me. I understand
that if it is determined that I shared my assignment with another person,
or copied my assignment from another person's work, then I and the other
person will suffer the following consequences: 1. This assignment will be
graded as a zero. 2. A full letter grade will be removed from the final grade
for the course I am taking. 3. A letter will be placed in my permanent file
in the School of Computer Science. 4. If this is a second transgression,
then I will receive an F in this course. My case will be forwarded to the
Dean for further action.
Create a utility class in a package named utilities. Add two static methods
to the class.
-
A static method that will return a string containing your name enclosed in
a predefined HTML heading.
-
A static method that will return a string containing the above oath. Include
an HTML horizontal rule at the start of the string.
Create a controller servlet in a package named hw2_servlet that will control the above JSPs.
-
Set an attribute that contains the output of the method in the utility class
that returns your name.
-
Set an attribute that contains the output of the method in the utility class
that returns the oath.
-
Create a method in the servlet that returns a string that contains the HTML
for all the hidden fields.
-
Set an attribute that contains the output of the method that returns the
HTML for all the hidden fields.
-
Since the JSP files are not in the directory to which the controller is mapped, you
cannot use a reference that is relative to the current directory when calculating the
address of the JSPs. You will need to use an address that starts from the root of the
web application.
-
Every time you change the .class file for the servlet on ocelot, you will need to reload
the web application.