3
1
|
I'm trying to use HttpSessionListener:
web.xml:
UserManager.java:
It works, but little bit strangely.
If i logout, it reports to the console:
If login, there is nothing in console.
What I'm doing wrong?
| ||||
|
10
|
A session is created the moment your browser makes a request to the webserver, not when you 'log in'. A session will always exist for each client that the server is interacting with. It does not matter if you store anything in that session or otherwise make use of it.
When you logout, you force the server to discard the current session, but since it still needs to communicate with the client a new ('clean') session is created. This new session is likely still in effect when you log in.
I'm sure if you shut down your server and delete all its working cache, you'll see the session created message on the first hit from your browser.
| ||||
1
| session = (HttpSession) context.getExternalContext().getSession(true); The above line in the logout method should have 'getSession()' without true.
| ||||||||
|