ie from a request you can access the session, so changes should be made in this direction, not the other way.
Do not try to store the request on the session or mix the request and session listener in the same class as these would be dangerous ideas.
SO i thought HttpSessionListener is the better way to go. Then where should i set the session attribute?
Originally posted by BTW:
I am not setting request parameter as a session attribute. Instead i am doing some LDAP query based on the request parameter and the output of the query is stored in session attribute.
SO i thought HttpSessionListener is the better way to go.
To go for what? You haven;t explained exactly what it is you are trying to do. Do you know what a session listener actually does?
If you are trying to store a parameter passed in a request, you'd set it into the session in the handler (doGet or doPost) for that request.
Users logs into the application with his empid. Once he logs in i have to find the empname, city ect by seaching LDAP using his empid which will be stored in request object which i am retrieving by request.getUserPrincipal().getName();.
Users may not enter to the same page all the time like, he can log into http://localhost:8080/App/Myapp or even he can log into http://localhost:8080/App/Myapp/AddNew. And i cannt place the code to look for the details(empName,city etc) in each possible servlet. That means i have to place the code in a place which will execute once new session starts. And as HttpSessionListener listens to any new session creation i thought i can place the code in the session listener class. But i will not be having access to request object.
So i want to know where can i set the session attributes? I hope this post explains everything. If it is not please let me know your doubt as it is very important.
Thanks in advance