Question: In this lab you are going to implement basic login and logout operations using the Servlet Session Tracking API. Create a Java class User that
In this lab you are going to implement basic login and logout operations using the Servlet Session Tracking API.
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 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 In doGet display a login form, eg
Username:
Password:
The form should submit data to the Login servlet using a POST request.
c In doPost check if the submitted username and password match any user in the list of users. If a match is found ie login is successful set a session attribute user whose value is the User object that matches the
submithed username and password, then redirect to the Members servlet. If no match is found ie login fails redirect back to the login form.
Create a servlet members. This servlet first checks if the session attribute user is set. If so it displays the following:
Hi
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
