File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Can tomcat apps talk to each other? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Can tomcat apps talk to each other?" Watch "Can tomcat apps talk to each other?" New topic
Author

Can tomcat apps talk to each other?

Clifford Adams
Ranch Hand

Joined: May 12, 2004
Posts: 50
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

Joined: Mar 22, 2000
Posts: 12803
    
    5
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

Joined: May 12, 2004
Posts: 50
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

Joined: Mar 22, 2000
Posts: 12803
    
    5
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.
 
subject: Can tomcat apps talk to each other?