This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
What are you basically trying to do?? Your ListenerDemo1 class implements only HttpSessionListener so it will not be notified of context initialization so don't expect that contextInitialized(ServletContextEvent e) method will be called. Also in the sessionCreated method, you are calling se.getValue("Name") method (which is depricated) on a new session. Now how is a new session supposed to have any attributes??
i already imported that packages. my requirement is i need to monitor all currently active sessions in server side. That monitoring needs all sessions and values from all sessions (These sessions all are already created by users) all sessions have attribute name and values. So I how can I get values from those sessions.
I not aware of anyways to get all the active sessions on the server - you could use listeners to update you when things happen on any user session but I don't think there is any mechanism to get all the active sessions.
Depending on your Servlet container there are usually monitoring tools supplied to view session activity. If its Tomcat see this. Assuming you know the names of the attributes in the session you can also get the values associated with them.