• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to get the list of existing sessions

 
Ranch Hand
Posts: 158
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi All,
I am using some methods which are deprecated in Java Servlet API 2.1. I want to find the alternative, but the description in javadoc says that : Deprecated. As of Java Servlet API 2.1 with no replacement.
I want to get the reference of all the existing (valid) sessions that has been created when the doGet or doPost of that servlet is invoked by a HttpServletRequest. I used HttpSessionContext.getSessionContext(); and from I obtain the enumeration of session IDs. but the method is deprecated.
Kindly let me know of nay alternative to get the list of sessions. I need the solution fast.
regards and thanks in advance
Tanveer

Basically what I want to do is to restrict only one session from one IP (machine) at a time. The simplified code is somewhat like this:

[ September 12, 2002: Message edited by: Tanveer Rameez ]
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Tanveer Rameez:
I used HttpSessionContext.getSessionContext(); and from I obtain the enumeration of session IDs. but the method is deprecated.
Kindly let me know of nay alternative to get the list of sessions. I need the solution fast.


Hi, Tanveer,
I've encounterd a similar problem and have not solved it yet, but I think I just found the solution on the webpage of More Servlets and JavaServer Pages. Go to
Chapter 10 and locate the sourcecode for SessionCounter.java.
This class is an exampe for a Session Listener (available since Servlet 2.3) which offers the following 2 methods:
public void sessionCreated(HttpSessionEvent event)
public void sessionDestroyed(HttpSessionEvent event)
Those can be used to get some Information about the sessions. Like described in this example you can save the relevant information in the servlet context and make it available to the servlet.
Hope it helps, I will try it out tonight...
Hartmut
[ September 12, 2002: Message edited by: Hartmut Ludwig ]
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic