Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can tomcat apps talk to each other?

 
Clifford Adams
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We have a large collection of lookup tables in our DB that we anticipate using in many applications. Is it possible to have a 'reference app' that fetches a bunch of values and keeps them in memory so they are available to other apps? How do the apps communicate? Thanks.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is one important distinction - whether or not the various servlets belong to the same "web application" and share the same web.xml and ServletContext.
If they are all in the same ServletContext, then you can store named "attribute" references in the ServletContext.
One of the major design requirements for the servlet API was keeping web applications cleanly separated.
Do these values change during the lifetime of a servlet?
Bill
 
Clifford Adams
Ranch Hand
Posts: 50
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply.

No, they would look up the values, store them in a list or something, and just sit there. they would need to be available to several apps, each with a different context and web.xml. We would them somehow re-run it daily or maybe weekly.

Could I package all of this into a jar file and put it in TOMCAT_HOME/shared/lib ?

Maybe use RMI? (I know nothing about this, but it looks possible) Maybe a web service?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest thing to do would be to save these values as a serialized collection object to a file that all the apps can locate. If you have not done serialization before you will be surprised at how simple it is.

A Map makes a good Collection to organize multiple chunks of data with names as keys - thats the way HttpSession objects handle things.

Bill
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic