Help coderanch get a
new server
by contributing to the fundraiser
  • 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
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

How can I load .properties file located outside the application as resource bundle?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How can I load .properties file located outside the application as resource bundle and use it in my JSPs?

The idea is that the properties file is located somewhere outside of the WAR and can be anywhere in the file system. It is also not referenced in the classpath.

The final design is to use <fmt:message> JSTL tag in my JSPs, but so far I found out that I can use only bundles which are referenced via the classpath.

Any suggestions?
 
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Why do you need to keep the properties file on the filesystem outside the app? Cant you package it as a part of your webapp?
 
Ivan Davidov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is only for example, in the real case I have multiple .properties files + multiple additional resources which can be at any place in the file system. I have specifications which say that the location is to be defined later => it is random for now and most probably will to stay random (changable location).

Yes, I can package the .properties file in the WAR or include the directory of .properties file to the classpath of my JBoss.

No, this will be only temporary solution.

Thanks anyway, I appreciate it!

Any other suggestions?
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
We had a similar requirement. We had to build an EAR and deploy the same EAR to all environments, but some configuration had to be different in each. It was XML, not properties so it's not exactly the same. Can you just code the full path to your properties file? c:\folder\file or /home/folder/file

BTW: We got out of this business and put all the config in a database table. Each environment has its own database.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there,

Use the URL class. I've had similar problem some weeks ago but in OSGi environment. Pay attention on the class ResourceBundle.Control too.
And finally, take a look at this articles:

http://wimpi.coalevo.net/2007/05/ant-me-outgenerating-obr-bundle.html

and

http://bordet.blogspot.com/2007/01/utf-8-handling-for-resourcebundle-and.html

You can compile the way of loading the bundle by your own now
Take care!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic