Invalidating session in struts2
Step 9: Create Once done with all the steps specified above run the application and see the following output in the browser.
In the do Filter method we will redirect user to login page if he tries to access other page without logging in.
Just deploy the application in your favorite servlet container, mine is Apache Tomcat 7.
Below images show us the different outputs for different URLs.
Servlet specification ensures that, the minimum features provided make the session management job easier.
Servlet API will use one of the underlying traditional mechanisms like cookies, URL rewriting, but that will happen behind the scenes and you need not worry about it!
Every request is associated with an Http Session object.
If the username and password does not match an error message is displayed as “Incorrect username and password” .
We will be using JSF view for login, DAO object , Http Session for session management, JSF managed bean and mysql database. Note that database operations code is not optimized to be used in a real project, I wrote it as quickly as possible because the idea is to learn authentication in JSF applications.