Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / April 2008

Tip: Looking for answers? Try searching our database.

Tracking requests without counting

Thread view: 
Jack - 10 Apr 2008 11:47 GMT
Hello,

In a Servlet (in Tomcat) is there a way to obtain the number of active
sessions or current requests without having to create some kind of
counter which is incremented as sessions arrive (maybe through a
filter) and decremented as sessions leave (maybe through a filter).

For example, is there something in the ServletContext or anything
similar?

I think the Tomcat manager displays the number of current sessions,
does it use an API for this? If so, can I use the same API within a
servlet?

Many thanks,
Jack
gunduzcan@gmail.com - 10 Apr 2008 13:23 GMT
> Hello,
>
[quoted text clipped - 12 lines]
> Many thanks,
> Jack

Try using SessionListener for monitoring session activity.

Gunduz
Jack - 10 Apr 2008 13:37 GMT
On Apr 10, 1:23 pm, gunduz...@gmail.com wrote:

> > Hello,
>
[quoted text clipped - 16 lines]
>
> Gunduz

Hi Gunduz,

Thank you for your response.

If I implement SessionListener, and am subsequently notified of
session activity, presumably I would then increment or decrement a
counter of some-kind.  I am trying to avoid this.  Have I missed
something?

Cheers,
Jack
Arne Vajhøj - 10 Apr 2008 23:47 GMT
> If I implement SessionListener, and am subsequently notified of
> session activity, presumably I would then increment or decrement a
> counter of some-kind.  I am trying to avoid this.  Have I missed
> something?

It is fundamentally impossible to keep track of something
that increases and decreases without keeping track of it.

The only question is whether the server does it for you or you
have to do it yourself.

And if relying on the standard then you have to do it
yourself.

It is very few lines and you should be able to find
plenty of examples.

Arne
Jack - 11 Apr 2008 08:41 GMT
Hello Arne,

Thank you for you response.

> > If I implement SessionListener, and am subsequently notified of
> > session activity, presumably I would then increment or decrement a
[quoted text clipped - 3 lines]
> It is fundamentally impossible to keep track of something
> that increases and decreases without keeping track of it.

Er, OK.  I mean, I could use an API which does the counting for me?
That was I don't have to keep track of it.

> The only question is whether the server does it for you or you
> have to do it yourself.

Yes, this was my original question.

> And if relying on the standard then you have to do it
> yourself.

So your saying the standard way is to do it yourself, but you're also
suggesting that I could NOT rely on the standard, and therefore do it
another way?  What is this other way?

> It is very few lines and you should be able to find
> plenty of examples.

It is not the number of lines of code or complexity etc.  I have a
rather strange situation where I am trying to find a solution whereby
I do not have to program a counter, but that Tomcat does this for me.
This was my original question.

> Arne

Cheers,
Jack

Yes, this is my original question.  Is there a way to OBTAIN the
number of active sessions.  I phrased this carefully, since I didn't
want to keep track of them myself.

I'm confused about your sentence 'if relying on the standard then you
have to do it yourself'.
Jack - 11 Apr 2008 08:43 GMT
> Hello Arne,
>
[quoted text clipped - 42 lines]
> I'm confused about your sentence 'if relying on the standard then you
> have to do it yourself'.

Typo, it should read 'That way I don't have to keep track of it.' not
'That was I don't have to keep track of it.'
Arne Vajhøj - 16 Apr 2008 03:11 GMT
>> And if relying on the standard then you have to do it
>> yourself.
>
> So your saying the standard way is to do it yourself, but you're also
> suggesting that I could NOT rely on the standard, and therefore do it
> another way?  What is this other way?

I believe that:
- there are no way specified in the Java EE standard to ask the
  container for the info
- there may be app server specific ways of doing it

I would not recommend using app server specific ways to avoid
writing so little and so trivial code.

And BTW I don't know any app server specific way for any of
the servers I have been using. But then I have not been
looking for it.

>> It is very few lines and you should be able to find
>> plenty of examples.
[quoted text clipped - 3 lines]
> I do not have to program a counter, but that Tomcat does this for me.
> This was my original question.

You have a very unusual context. Don't expect a standard solution
for it.

Arne


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.