• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Some errors with my ActiveSessions counter

 
Jenkin Zheng
Greenhorn
Posts: 12
Eclipse IDE Java Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
may be because you are printing it too early..
print it after the if/else block after you set the attribute in your code..
 
syed aq
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Donot use listener, in rare cases listeners are not fired
 
Piyush Joshi
Ranch Hand
Posts: 207
Eclipse IDE Firefox Browser jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic