I have a login page which asks for username and password. On clicking on login button, web page sends username and password to login servlet as parameters (I am using tomcat). Then, I am creating a session using request.getSession();
I have a sessionListener class (implements HttpSessionListener
) where I am overriding sessionCreated()
and sessionDestroyed()
methods. I have also made listener entry in web.xml file.
My problem is, I want to access the username request parameter inside sessionCreated()
method so that I could write the username into mysql database whenever a new session is created.
Basically, is there any way that we can access user entered parameters inside session listeners? Please suggest how can I achieve this.