Homework 1
CS320, Winter 2012


Due: Tuesday, January 31

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


[Readings]

[CS320Wiki]

This quarter we are going to implement a simple wiki which we'll call CS320Wiki. In this assignment, you are going to implement some basic features using servlets or a combination of servlets and HTML pages. A video illustrating these features is available here.

In your application, the wiki pages should be accessed at the URLs that begin with http://<host>/<application>/wiki/, e.g. http://<host>/<application>/wiki/mypage1. Note that <host> is the host name of the server with port number (optional), e.g. localhost:8080; in Eclipse, <application> is the project name, and on CS3, <application> is the name of your account, e.g. cs320stu31.

A wiki page is uniquely identified by its path, which is the part of the URL that follows /wiki/. For instance, in the example above, the path of the wiki page is mypage1. In this assignment you must pre-create a wiki page in your application with the path index. The content of the page should include the following:

Welcome to CS320Wiki. To see all the pages currently hosted on the wiki, please click on Page List.

1. (40pt)  A user may try to access a wiki page at the URL http://<host>/<application>/wiki/<path>. If the wiki page already exists, the application should display its content, and at the bottom of the page, the author and the time when the page was created. For example: 

Welcome to CS320Wiki. To see all the pages currently hosted on the wiki, please click on Page List.

Page created by John Doe at 2012-01-10 11:21AM.

If a user tries to access a wiki page that does not exist, the application should display the following:

The page <path> does not exist. Do you want to create it? Yes No

Note that <path> should be the path of the wiki page that the user tries to access. Clicking on Yes should take the user to a page where the wiki page can be created (as described in the next exercise), and clicking on No should take the user to the wiki page index.

2. (30pt)  To create a wiki page, a user must provide their name and the content of the page, as shown below:

CS320Wiki - New Page
Path: <path>
Your Name:
Content:

Again, <path> here is the path of the wiki page to be created. After the user clicks the Create button, the application should redirect the user to the newly created page.

3. (30pt) When a user clicks on Page List on the wiki page index, the application should display a list of all the wiki pages. For example:

CS320Wiki Page List
Path Created By Creation Time
mypage Chengyu Sun 2012-01-20 08:01AM
cs320/homework1.html Chengyu Sun 2012-01-16 07:10PM
index John Doe 2012-01-10 11:21AM
Back To Wiki

For each wiki page, the list should include its path, name of the user who created the page, and the time when the page was created. The list should be sorted by the time of creation in descending order.

Clicking on the path of a page should take the user to that page, and clicking on Back To Wiki should take the user to the wiki page index.

[Notes and Hints]