Tracking HTTP Session by using HttpSessionListener

Servlet

In web application, sometimes we need to track existing sessions on server, for example we need to get actual HTTP session from session ID. Following I will show you simple HTTP session listener to keep existing sessions during creation time, then get stored session based on session ID. Below sample code will store valid sessions into memory for debugging and controlling purpose.

Below is additional code in web.xml for enabling above listener:

You can call 2 methods in HttpSessionCollector class from caller as follow:

Hope this article helps you in tracking HTTP session on your web application.

For reading another JSP/Servlet articles, you can click here.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*