*
The moose likes Servlets and the fly likes Some errors with my ActiveSessions counter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Some errors with my ActiveSessions counter" Watch "Some errors with my ActiveSessions counter" New topic
Author

Some errors with my ActiveSessions counter

Jenkin Zheng
Greenhorn

Joined: Mar 31, 2011
Posts: 12

Hi, everyone! I want to count active sessions on server. So I implement javax.servlet.http.HttpSessionListener, Here is a part code of SessionCounter
Here is my test the counter code:
Sometimes, the result is not right, like:[null]active sessions on server.
Why does it show null?I'm a newer!
thanks, everyone!
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

may be because you are printing it too early..
print it after the if/else block after you set the attribute in your code..


Piyush
syed aq
Greenhorn

Joined: Jul 16, 2011
Posts: 3
Donot use listener, in rare cases listeners are not fired
Piyush Joshi
Ranch Hand

Joined: Jun 10, 2011
Posts: 207

syed aq wrote:Donot use listener, in rare cases listeners are not fired

Can you please explain what are the cases when listeners will not be fired. (except when the server crashes)
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Some errors with my ActiveSessions counter