1 Reply Latest reply on Apr 12, 2012 6:06 AM by murali veligeti - oracle

    Obtains a list of session ID


      I would like obtains a list of active session (session id) on weblogic.

      Is it possible?

        • 1. Re: Obtains a list of session ID
          murali veligeti - oracle

          There is no way to list all the sessionIds present in weblogic server.

          But you need to implement your own mechanism where you can retrieve all the session IDs. For this you need to implement HttpSessionListener where when ever you create a session store the session id in ArrayList and when ever the session is destroyed remove from the ArrayList and this ArrayList will have the sessionids present in weblogic server. Please find the implementation below.

          import javax.servlet.*;
          import javax.servlet.http.*;
          import java.util.Map;
          import java.util.HashMap;
          public class ListenerSession
          implements HttpSessionListener {

          public List sessionIDList = new ArrayList();
          public ListenerSession() {
          public void sessionCreated(HttpSessionEvent sessionEvent) {
          // Get the session that was created
          HttpSession session = sessionEvent.getSession();
          public void sessionDestroyed(HttpSessionEvent sessionEvent) {
          // Get the session that was invalidated
          HttpSession session = sessionEvent.getSession();

          Please let me know if you face any issues in implemention Listeners.

          Thanks & Regards,