Homework 2
CS320, Fall 2007
Due: Wednesday, October 17
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 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.
[Reading]
- Textbook Chapter 6, 7, 8,
and 9, especially Section 7.5.
[Login
and Logout] (40pt)
Movie review sites usually allow all visitors to view the ratings
and reviews of the movies, but only allow registered users to rate
and/or review movies. For this assignment, you are going to add this
feature to the movie review servlet you developed in Homework 1.
In particular, whenever a user tries to add a movie or review a movie,
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
implementation you choose, it has to meet the following requirements:
- The login procedure cannot
be
bypassed.
- User authentication must
happen on the server side.
- Once a user is
authenticated, a session is created so the user
won't be asked for username and password repeatedly. A user may also
choose to "logout", in which case the session should be terminated.
For session tracking, you must use Servlet Session Tracking API.
- Username "cysun" with
password "abcd" must be an valid account.
- Username "cs320stu31" with password "abcd" must be another valid account.
Note that once you complete the Login feature, a few changes must be made to the user interface. In particular:
- A Logout link or button should be shown after a user is logged in, and if a user clicks Logout, he or she will be logged out and redirected to the movie index page.
- The name of the user is no longer needed when a user reviews a
movie, because the user would have already signed in and the server
should keep track the information of the user as a session attribute.
- In the page where the reviews of a movie are displayed, if a user already reviewed the movie, instead the Rate This Movie link, it should display an Edit My Review link (see next section for more details).
[Edit Review] (30pt)
A user may later changes his or her opinion about a movie, thus
needs to edit his or her review of the movie. Implement this
feature in your servlet. Note that the interface for editing a review
is almost
identical to the interface for adding a review shown in Homework
1,
except that when a user edits a review, the form should be pre-filled
with the current information of the review.