Session Management

Hello,

I am using tomcat 5.5 and I want to manage my sessions so that I can

have a method like getSessions()... or set a constrain on a session

parameter, like session.getAttribute("user").setLimit(1);

Is this handled internally (J2EE API) or do I need tomcat libraries to do

that?

I have browsed around but probably I am not using the correct search terms, so even a search term will help.

Thanx,

John

[458 byte] By [johndel6a] at [2007-10-2 6:15:53]
# 1

You want an HttpSession to know about other HttpSessions? They should not know about one another. If you "really" need this functionality, you'll likely have to modify the servlet container yourself. I don't know what you are trying to do, but perhaps there is another way to get the functionality you are trying to code.

Good luck.

filestreama at 2007-7-16 13:17:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Thank you for your answer....

Basically what I am trying to do is to identify:

1.How many sessions exist in my context?

2.Who do they belong to? (They may belong to a logged user which can

be found through the database or it may not).

Is there any common tecnique regarding session management or I have to just do it through the database.

Thanx again.

johndel6a at 2007-7-16 13:17:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Check out the HttpSessionListener http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/http/HttpSessionListener.html
tolmanka at 2007-7-16 13:17:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
tolmank is right however, unless you know what you are doing, you may want to use HttpSessionBindingListener.How are you tracking users? cookies?
filestreama at 2007-7-16 13:17:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 5
I dont know how do I track them. I use request.getSession() and then use this Session object.I will check HttpSessionBindingListener.Thanx
johndel6a at 2007-7-16 13:17:42 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 6

Hi,

we are using the struts and the method we had used to track the number of session

is to make a listener class that keeps track of the number of session made by the user

to do this

u need to implement the HttpSessionListener, HttpSessionAttributeListener

and do the required coding in the sessionCreated() method by a counter.

U had to register the listener in the web.xml

search the listener+web.xml on net

deepak.tewari@ubicsindia.com at 2007-7-16 13:17:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 7
> Hi,> we are using the struts...whilst you may be using a struts-independent way of tracking users and their sessions, be mindful that not everyone uses or wants to use a framework. Best to have generic solutions.
filestreama at 2007-7-16 13:17:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 8
Hi,its an generic solution,nothing to do with the Strutsfor any application u can define the listener in the web.xml, which can track the number of sessions.
deepak.tewari@ubicsindia.com at 2007-7-16 13:17:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 9

> Hi,

>its an generic solution,

>nothing to do with the Struts

> for any application u can define the listener in

> in the

>web.xml, which can track the number of sessions.

Deepak, you are right. Declaring a listener in web.xml is generic. However, I just wanted to point out that some people only know how to do things within the context of a particular framework.

regards.

filestreama at 2007-7-16 13:17:43 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...