Question: In this lab you are going to implement basic login and logout operations using the Servlet Session Tracking API. ( 1 0 pt ) Create

In this lab you are going to implement basic login and logout operations using the Servlet Session Tracking API.
(10pt) Create a Java class User that represents a user. In particular, the User class should have at least three properties: name, username, and password. You may add additional properties like id
if you want.
Create a servlet Login as follows:
(a)(10pt) In the init() method of the Login servlet, create at least two User objects. One of the User objects must have the following property values:
name: "John Doe"
username: "jdoe"
password: "abcd"
Add the User objects to a list and save the list in application scope.
(b)(20pt) In doGet(), display a login form, e.g.
Username:
Password: [
The form should submit data to the Login servlet using a POST request.
(c)(30pt) In doPost(), check if the submitted username and password match any user in the list of users. If a match is found (i.e. login is successful), set a session attribute user whose value is
the User object that matches the submitted username and password, then redirect to the Members servlet. If no match is found (i.e. login fails), redirect back to the login form.
(20pt) Create a servlet Members. This servlet first checks if the session attribute user is set. If so, it displays the following:
Hi,==
 In this lab you are going to implement basic login and

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!