Hello everybody!
Here is the second version of the "Servlet Login Logout Example". This time I used session instead of cookies. The code and the appearance of the pages are pretty such the same with
the first version. I will still add everything here to provide an easy flow for you.
So here is the index.html.
|
index.html |
When the user clicks the login button, we ask him/her to enter username and password. After checking if they match with the correct information, we then can store user information in a session object to identify the user across the other pages within the application. So the "LoginServlet" does this job as you can see below.
|
LoginServlet |
After a successful login, the user will see the page below. Once logged in, the user will see his/her name on the welcome page. The user now can view the profile page or log out.
|
welcome page |
Clicking the "Profile" link on the welcome page, "Profile Servlet" will be called. The content of it can be seen down below.
|
ProfileServlet |
Clicking the "Logout" button, the session will be deleted by "LogoutServlet".
|
LogoutServlet |
If you want to have a look at the web.xml file, I will add a screenshot just below.
|
web.xml |
Hope to see you in the next blog post.
Selen
No comments:
Post a Comment