Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 10:28 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 2 posts ] 
Author Question
 Question subject: tomcat session tracking
PostPosted: Wed Oct 22, 2008 1:50 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:47 pm
Posts: 281
Has thanked: 0 time
Have thanks: 1 time

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.


TOP
 Profile Send private message  
Reply with quote  
 Question subject: Re: tomcat session tracking
PostPosted: Wed Oct 22, 2008 1:51 am 
Offline
Proficient
User avatar

Joined: Sun Oct 19, 2008 3:53 pm
Posts: 229
Has thanked: 0 time
Have thanks: 0 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...


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 2 posts ] 
Quick reply


  

 Similar topics
 how to write code message to user before session will expire
 i need code for identifying web user session
 EJB session bean
 PHP session variables problem in Firefox
 PHP session variables problem in Firefox
 php login with session
 Session handling using Struts
 Session destroy on navigate away
 session in jsp
 Login using session with php and mysql

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team