• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Properties File sharing across Mulipe Web applications

 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have four different web applications running in my tomcat 6 server. I have some resource details like URL of each applications stored in the properties file to be used for the menu. There are other details as well

The problem is these details are duplicated across applications and while testing or deployment, each URL need to be updated in all the properties file.

Is there any way to make this properties file as common so that all the applications can access the same file.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I understand you correctly, you have a common properties file for multiple webapps.

The easiest way to do this - especially if you want to be able to use an alternate properties file for testing - is to place the properties file in an external location outside of the webapps and configure each webapp to use that file. For example, "/etc/mywebapps.properties" if you're on a unix/linux server.

You can make this location programmable by setting up a resource-reference in web.xml and setting the location (filename path) as a Context resource definition in each webapp's Context. You would then be able to retrieve the pathname of the resource file using JNDI (for example, "java:comp/env/webapp-properties", then open and load the properties using normal Java file I/O and System.properties calls.
 
Ramkumar Subburaj
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes your understanding is correct.

But our applications can be deployed in different locations under different OS.

So again this becomes a burden for the client who will decide where to deploy.

 
Tim Holloway
Saloon Keeper
Pie
Posts: 18277
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ramkumar Subburaj wrote:Yes your understanding is correct.

But our applications can be deployed in different locations under different OS.

So again this becomes a burden for the client who will decide where to deploy.



That's an even more compelling reason to go that route. JNDI is OS-independent and you can set the location of the properties file path from the Tomcat admin webapp if editing Context files is an issue.

addendum: I spent several years in an environment where our development machines were Windows but the test and production servers were Solaris and later Linux. So I do have experience in this technique.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic