Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

httpsessionlistener in distributed application

 
osman cinar eren
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

i have a simple servlet that counts the people on the site: a listener which implements httpsessionlistener; there is a counter in the application context, it is updated in a synchronized block.

Everything is OK when the application runs on one web container. But how can i have a counter if the application runs on two web containers?

i will appreciate any ideas.

thanks in advance.
best regards.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You would have to tell us a little bit about how you are deploying your app.
Are you using session replication, IP Load balancing, a common database?
 
osman cinar eren
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,

actually i have implemented a portlet which runs on Websphere Apllication server. There will be two WASs and the requests will be given to them by IBM Edge Servers. I dont know the details about the edge servers, but i can learn if you wish.
 
Sarath Mohan
Ranch Hand
Posts: 213
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One more we have a tag distributable in web.xml? Will this help?
 
osman cinar eren
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont think so as there will be 2 application contexts and i must have the sum of the values in them.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not that familiar with WAS.
I believe, if you're using session replication, that the session events would be fired on all machines in the cluster (I'm not certain of this though).

If this is not the case, you could, if you are using a shared database, write your session counting data to it from both apps. You might also want to look into Java Messaging Service (JMS) and/or Java's Remote Method Invocation (RMI).

My own solution to this was to build a split-screen webpage that shows both servers, each in their own frame. Since I'm the only one who uses it, this cheap, 5 minute hack is more than sufficient.
Your needs may vary.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic