• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Properties File sharing across Mulipe Web applications

 
Ranch Hand
Posts: 83
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
The overall mission is to change the world. When you've done that, then you can read this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic