The problem is you want a page to be 'loaded' when the window is closing.
In order to load a page you have to have a window....
Lets now look in detail as how to create a JSF login logout authentication mechanism in JSF application. 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.package com.dao; import
Step 1: Create the table Users in mysql database as Before we move on to our project related code, below image shows the project structure in Eclipse.
You cannot click on the profile page untill you are logged in.
The commonly used methods of Session Map class are as follows: This example contains three links login, logout and profile.
This action class implements the Session Aware interface and overrides the set Session method to store the information in the session scope.
For logout, we are simply calling the invalidate() method of Session Map.
Fortunately, sessions expire automatically after a period of time; check your servlet engine documentation to see how to set this timeout period.
I felt that there should be a way to do it from Java Script; unfortunately, Java Script doesn't seem to have an handler that you want.
The struts 2 framework passes the instance of org.apache.struts2.dispatcher. If the end user clicks on the logout link, he will not be able to access the profile page.