Question: Need help in implementing a basic login and logout operations using the Servlet Session Tracking API (NOT Cookies). In doPost(), check if the username and

Need help in implementing a basic login and logout operations using the Servlet Session Tracking API (NOT Cookies).

Need help in implementing a basic login and logout operations using the

  • In doPost(), check if the username and password match ericc and 123456, respectively. If the username and password are correct, set a session attribute user and redirect the user to the Members servlet; if not, redirect the user back to the login form. You may add additional accounts if you want, but ericc/123456 must be a valid account so we can test your code. Hints: You may store the pre-defined username and password information in servlet application scope and initialize the application scope in the init() method.

Note: Do NOT store the username and password in Cookies. If you do that, other people can easily get your username and password.

2. Create a servlet Members. This servlet first checks whether the session attribute user is set. If so, it displays the following:

Hi, ericc. Welcome to the Members Area

Logout

Otherwise, it redirects the user back to the login form.

3.Clicking on Logout should take the user to a Logout servlet which invalidate the session (i.e. calling the invalidate() method in HttpSession), then redirect the user back to the login form.

In doGet(), display a login form, e.g. Username: Password: Login In doGet(), display a login form, e.g. Username: Password: Login

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!