Homework 2
CS320, Spring 2006


Due: Thursday, April 20

Please upload your files using the 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]
[Login and Logout] (40pt)

Blog applications usually allow all visitors to view the content of the blogs, but only allow registered users to create new posts or add comments. For this assignment, you are going to add this feature to the blog servlet you developed in Homework 1. In particular, whenever a user tries to create a new post or add a comment, the servlet should first check whether the user is already logged in. If not, the user should be redirected to a Login page, where they must provide a valid username and corresponding password.

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:

Note that once you complete the Login feature, you need to modify the user interface for adding comments so that it no longer asks for username, because the user would have already signed in and the server should keep track the username as a session attribute.

[Create New Posts] (40pt)

Instructor's Announcements
New Post Logout

Tuesday, April 4, 2006

Homework 0 Due Tonight at 11:59PM
Please upload your files on time.
Posted by cysun at 4PM, 2 Comments

Sunday, April 2, 2006

Homework 1 Posted
Homework 1 is posted on the class home page. Please check it out and let me know if you have any questions.
Posted by cysun at 1:21PM, 0 Comments

Tuesday, March 28, 2006

Homework 0 Posted
Homework 0 is posted on the class home page. It's quite simple.
Posted by cysun at 9:00AM, 0 Comments

Title:
Content:
(a) (b)
Figure 1. Interface for Creating a New Post

Modify your servlet so that a user can create new posts. For example, add a "New Post" link or button as shown in Figure 1(a), and when a user click on the link, the servlet displays a web form so the user can type in the title and the content of the new post, as shown in Figure 1(b). Note that only the owner of a blog can create new posts in that blog, while any user, once logged in, can add comments to any post.