• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Knute Snortum
  • Bear Bibeault
Saloon Keepers:
  • Ron McLeod
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Ganesh Patekar
Bartenders:
  • Frits Walraven
  • Carey Brown
  • Tim Holloway

Can tomcat apps talk to each other?

 
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.
 
Author and all-around good cowpoke
Posts: 13078
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
Posts: 13078
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
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!