Total members 11892 |It is currently Fri Sep 20, 2024 5:09 am Login / Join Codemiles

Java

C/C++

PHP

C#

HTML

CSS

ASP

Javascript

JQuery

AJAX

XSD

Python

Matlab

R Scripts

Weka





As a part of my project (using servlets and tomcat 6 webserver), I want
to list all active tomcat sessions. Can anybody help me with source
code.




Author:
Proficient
User avatar Posts: 280
Have thanks: 1 time

* There is no way to get the all session ids apart from HttpSessionContext.
*

*But you can implement it yourself with a collection. *

*Make a class that is using hash map or hash table object which is global to
the application. Whenever a user logs in make an entry into hashmap or hash
table and remove it when he/she logs out. *

*At any point you can retrieves keys and their values from that class that
coresponds to user identification and session object. *

*for example if you are using JSP look at this code- *

*...

<jsp:useBean id="allsessions" scope="application" class="java.util.HashTable"/>

...

Code:
<%
allsessions.put(userid,session);
String user=null;
Enumeration users= allsessions.keys();
while(users.hasMoreElements())
{
user = users.nextElement();
out.println("Userid ="+user);
out.println("session = "+allsessions.get ((String)user));
}
%>*


*[This code doesn't quite work -- where is "userid" acquired? How do you
capture logout? But it's a nice hack anyway...

_________________
Please recommend my post if you found it helpful


Author:
Proficient
User avatar Posts: 228
Have thanks: 0 time
Post new topic Reply to topic  [ 2 posts ] 

  Related Posts  to : tomcat session tracking
 How can I enable session tracking for JSP pages if the brows     -  
 tomcat server config     -  
 session in jsp     -  
 php login with session     -  
 PHP session variables     -  
 EJB session bean     -  
 Session Valid     -  
 Session destroy on navigate away     -  
 Modify Session Variables     -  
 Delete session variable     -  









Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team
Codemiles.com is a participant in the Amazon Services LLC Associates Program, an affiliate advertising program designed to provide a means for sites to earn advertising fees by advertising and linking to Amazon.com