• Post Reply Bookmark Topic Watch Topic
  • New Topic

What is the best way to share an object across multiple applications  RSS feed

Ranch Hand
Posts: 430
Android Debian VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have three applications that are deployed in Tomcat as three war files. I need to reuse existing code which at the moment manages the logged on user information in a hashTable defined as

The string key is the sessionID and the UserObject is a normal class that has the following methods

The three existing applications have to reuse these user management code which means all three have to use the same instance of the HashTable. I realize that there are better ways of implementing Single Sign services but i am in a position where i have no choice but to reuse existing code/implementation.

I am looking for ways where i can modify the existing applications so that they can access the same instance of the UserManager class which is the class that contains the HashTable. I plan to create a new war file that will contain the UserManager class and other common classes but now the problem is that the servlet spec does not allow acess to data on individual applications i.e. app1 cant access app2's data.

I have been looking around on Google and found that possible solutions.

Solution 1

Add a new application (app4) which the other three applications will use to authenticate the user. The existing war files (app1, app2 and app3) would use app4 for the authentication by using the following approach.

App4 initialises the UserManagerInstance

App1, app2 and app3 would refer to the object as

Solution 2

The other solution is to add the UserManager to a JNDI context and have apps1-3 access it via JNDI.


- Which of the two solutions do you think is better?

- With solution2, how will the UserManager object be initialised before it is put on the ? I am not very familiar with JNDi so would really like to see an example of how i can initialise the object on Tomcat's JNDI and how i can access it.

- The new application will basically be providing a service to the other applications. Is there a better way of providing this service bearing in mind that the framework in use is Struts 1.

Environment used
Tomcat 6
Solaris 9
Struts 1.2


Danger, 10,000 volts, very electic .... tiny ad:
Why should you try IntelliJ IDEA ?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!