title: Can I implement HttpSessionListener this way?
body: <p>I'm trying to tracking valid user Ids in my Java servlet, can I implement HttpSessionListener this way ?</p>
  
  <pre><code>public class my_Servlet extends HttpServlet implements HttpSessionListener
  {
    String User_Id;
    static Vector&lt;String&gt; Valid_User_Id_Vector=new Vector&lt;String&gt;();
    private static int activeSessions=0;
  
    public void sessionCreated(HttpSessionEvent se)
    {
  // associate User_Id with session Id;
  // add User_Id to Valid_User_Id_Vector
      Out(" sessionCreated : "+se.getSession().getId());
      activeSessions++;
    }
  
    public void sessionDestroyed(HttpSessionEvent se)
    {
      if (activeSessions&gt;0)
      {
  // remove User_Id from Valid_User_Id_Vector by identifing it's session Id
        Out(" sessionDestroyed : "+se.getSession().getId());
        activeSessions--;
      }
    }
  
    public static int getActiveSessions()
    {
      return activeSessions;
    }
  
    public void init(ServletConfig config) throws ServletException
    {
    }
  
    public void destroy()
    {
  
    }
  
    protected void processRequest(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException
    {
      User_Id=request.getParameter("User_Id");
    }
  
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
      processRequest(request, response);
    }
  
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException
    {
      processRequest(request, response);
    }
  
    public String getServletInfo()
    {
      return "Short description";
    }
  }
  </code></pre>
  
  <p>How to get the listener notified when a session ends ? I'm trying to bypass "/WEB-INF.web.xml" all together, is it doable ? Or does it make sense ?</p>