Homework 2
CS320, Spring 2006


Due: Tuesday, October 24

Please upload your files to CSNS. The files should include all the source code, documentation, and an HTML file hw2.html, which contains a link to your servlet on the CS server. Note that file uploading will be disabled automatically after 11:59PM of the due date, so please turn in your work on time.


[Reading]

[Folders] (40pt)

Modify the servlet you developed in Homework 1 so that an folder has an additional attribute type. The type of a folder can be either public or private. The pictures in a public folder can be viewed by everybody, but the pictures in a private folder can only be viewed by the owner of the album.

For this assignment, also add the feature to create new folders. For example, add a link (or button) to the user's home page which says "Create New Folder", and when the user clicks the link (or button), the servlet displays a simple form that looks like the following and lets the user to create a new folder:

Folder Name:
Descripton:
Public Private

Note that all picture operations (add, delete, edit) should work for user-created folders.

[Login and Logout] (30pt)

All public folders are viewable by everybody, but operations such as accessing private folders, adding, editting, or deleting pictures can only be performed by the owner of the album. In particular, if one of these operations is attempted, the servlet should first check whether the user is already logged in, and if so, check whether the user is the owner of the album. If either of these checks fails, the user should be redirected to a Login page, where they can login as the owner of the album.

It is completely up to you to decide whether to implement this feature with one servlet, two servlets, or some combination of servlets and HTML pages. However, whatever implemention you choose, it has to meet the following requirements:

[Edit Picture] (30pt)

Implement the Edit Picture feature which we left out in the last assignment. Note that the interface for editting a picture is almost identical to the interface for adding a picture shown in Homework 1, except that when a user edits a picture, the form should be pre-filled with the current information of the picture. Also note that a user should be able to use the Edit Picture feature to move a picture from one folder to another by simply selecting a different folder.