Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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).

image text in transcribed

  • 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions