Due: Tues, Mar 25th by 11:59 PM

Getting started

Download CS496_Assign04.zip and import it into Eclipse.

Your should see a project called CS406_Assign04 in your Eclipse workspace. Note that this project assumes that you have the CS496_Jetty project in your workspace (from Assignment 1).

The version of the zipfile posted prior to March 18th had an incorrect .classpath file, meaning that the none of the server-side code (such as the InventoryApp servlet, the controllers, and persistence layer) was actually executed.

To fix: right click the CS496_Assign04 project, choose Refactor → Rename, and rename it as CS496_Assign04_Copy. Download and import the corrected zipfile. Copy all of the code in the packages in the src folder from the old project to the new one.

Make sure that when you submit, you submit the new project.

Your task

Complete the web application so that it works like this one:

https://cs.ycp.edu/cs496/inventory

The web application corresponds very closely to the web service you implemented in Assignment 1. You should be able to reuse your controllers and persistence implementation from that assignment. (You will need to fix bugs in the persistence layer if there are any.)

The idea is that a URL which ends in /inventory displays the entire inventory, and a URL ending in /inventory/ItemName should display a single named item.

Item URLs can have an action parameter that will allow the user to view, edit, or delete an item. For example, a URL ending in /inventory/Apples?action=edit should allow the user to edit the Apples item.

Hints

Your webapp should use the MVC2 architecture as described in the notes for Lecture 10. InventoryApp.java is the servlet that will handle GET and POST requests sent by the client web browser. _view/inventory.jsp and _view/item.jsp are the views that will render HTML pages for the overall inventory and individual items, respectively.

A GET request should render a user interface appropriate for what the user wants to do.

Use HTML forms to allow the user to enter and submit updated information. Each form should do a POST that sends the completed form information to the same URL as the page containing the form. A form submission should (typically) display the same UI, along with a message describing the success or failure of the operation. One exception is deleting an item: the result page should just contain a message about whether or not the item was deleted successfully. This should give you a sense of how to use HTML forms.

The _view/item.jsp view should use the <c:if> tag to check the action and render an appropriate UI (for viewing, editing, adding, or deleting an item).

You may find the JSTL Tutorial and JSP Expression Language Tutorial useful for working with JSTL tags (such as <c:if>) and JSP expressions (such as ${Item.name}).

Use "View Source" in your web browser to see the HTML generated by the example inventory web application. This may be helpful as you work with HTML forms.

Grading

Your grade will be determined as follows (out of 100 points):

(*) You should research cross-site scripting and how to avoid XSS vulnerabilities in JSPs.

Submitting

Select the CS496_Assign04 project, then click the blue up arrow icon, and enter your Marmoset username and password when prompted.

Alternatively, export the CS496_Assign04 project to a zipfile, and upload the zipfile to Marmoset as assign04:

https://cs.ycp.edu/marmoset

Important: please do not submit the CS496_Jetty project as part of your submission. Only submit CS496_Assign04.