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)
|
|
|||||||
(a) | (b) |
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.