CGS4854, Homework 2
Due Friday, 3/1 (late 6am, 3/2)
If you had any errors in Homework 1, then fix them, so that you don't lose
points twice for the same mistake.
Apache
Apache server.
- Request
a port and start your server.
- Configure
your server.
- Add JkMount directives to the httpd.conf file for the following.
- All paths that start with /manager/*
- All paths that start with /username/*
- The path /username
- All JSPs.
- Remove the JkMount for examples.
- Add a folder named styles in the docRoot folder.
- Add a stylesheet to the folder.
- In the stylesheet, set the default background color and text color.
- Use contrasting colors so the text can be read easily.
- Set a default font using the font-family style. Choose at least three options for the font. The last option should be one of the generic fonts. All the fonts should share the same generic quality.
- Add an index.html (not .jsp) page to the docRoot
directory. The file is HTML not a JSP.
- Include all the standard tags.
- Validate the page.
- Include a relative link to the root of your web application for
homework.
- Incude a relative link to the root of your web application for
tutorials.
- Include a relative link to manager/html.
- Include a paragraph with at least four complete sentences, explaining your web site.
- Include the stylesheet for this page.
Create a Web Application using NetBeans
- If you have not already done so, create a web application in NetBeans, named your-username
(replace your-username with your user name).
- If there is not a web.xml file in the WEB-INF folder, then select
New File -> Web -> Standard Deployment Descriptor (web.xml)
from the NetBeans menu.
- Use the secure web.xml file.
- Restrict access to this web site to you and me (this is controlled by
the secure web.xml file)
- Edit the tomcat users
file so that you can access your app in your local NetBeans.
- Modify the index.jsp that is in the root of the web app. Be
sure it uses the HTML 5 DOCTYPE and Meta tags.
- Add a paragraph of at least four sentences that describes the service
that you are providing. These sentences must be different from the sentences in the index.html file in the docRoot.
- Validate the JSP at http://www.w3c.org.
- Use the stylesheet. The stylesheet only needs to work when the page is accessed from Apache.
- Add a link to the controller for this assignment.
- If you did the first homework, then the first homework should also have a link to it and should still work.
Reorganised Controller
- Implement a servlet controller for your application. The controller
should behave like the reorganised controller from Chapter 3 of the book.
- All the JSPs in the application should use the stylesheet. The stylesheet only needs
to work when the pages are accessed from Apache. This is different from homework 1: the stylesheet is in the Apache root, not in your web application.
- Modify Edit.jsp. Continue to use the three fields that you used in homework 1.
- Add default validation to at least one field.
- The user will enter data into the fields in the Edit page. Initialize
the input elements with the corresponding data in the query string.
- Do not use a default value like "No Hobby" or "No Aversion".
Choose a valid default value that makes sense in your site. You
must test for more than null and empty.
- Echo the value of all the fields from the bean in each page. Use the helper method from the bean.
- Bean
- Place the bean in the same package as the controller.
- Create a bean that has properties for the fields in your web application.
- Add default validation for at least one field. You do not need default
validation for all the fields, but you may validate all fields.
- Add an accessor to the bean that displays all the values from the bean in a complete sentence. Do not add a variable for this method. It is only a helper method.
- Create a controller helper for the web application.
- Place it in the same directory as the controller.
- Modify the controller helper so that it can process all four of your
pages.
- Modify the controller helper so that it uses your bean and
initializes your bean with the data in the query string.
- Change the name that is used to store the helper in the session (do
not use "helper"). This will change how you access your data in the
JSPs.
- Change the name of the getData method in the controller helper. This
will change how you access your data in the JSPs.
- Place the helper base file in the same directory as the controller. Do
not make any changes to the helper base file.
- Rewrite the controller so that it uses a controller helper.
- Place your JSPs in a visible subdirectory. Modify the pages so that they
use the helper in the session to access the bean and its properties.
- Add a hypertext link in the index.jsp page to the servlet mapping for
controller. Use a relative link.
- The web app must use the secure web.xml file and should only allow
you and me to access your application: Edit tomcat users
- Be sure to modify the project so that the .java files are placed
in the WAR file: Configuring WAR File
- After the app is running in NetBeans, upload it and run it on ocelot: Uploading a WAR file
ROOT Web Application on ocelot
Be sure you have the following links in the ROOT/index.jsp file on ocelot.
- Relative link to manager/html.
- Relative link to the root of your web application for homework.
- Relative link to the root of your web application for tutorials.
- Absolute link to your student host using your Apache
port.
Hand In Assignment
To hand in the assignment, zip the cgs4854 directory and upload it.
- Please use the following command to compress your cgs4854
folder.
zip -r username ~/cgs4854 -x \*.jar \*.zip \*.war
Replacing username with your user name. This will create a file
named username.zip. It contains the ROOT, manager and username web
applications.
- Check the size of the ZIP file, it should be less than 3 MB. If it is
not, then you probably have another ZIP file stored in the ZIP archive.
Delete it and re-zip.
- You then have a choice for submitting the file.
- If you are logged onto ocelot, use my uploading program to upload the
file. Enter this command at the command prompt:
~downeyt/public/webftp/webftp.pl
- If you are using winscp, then download the zip file to your computer;
then, upload the file to me: Submitting
homework on-line via the Web.
- 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.