This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

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

 
Ivan Davidov
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • 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?
 
Amol Nayak
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • 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
  • 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?
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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.
 
Nikolay Vasilev
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • 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!
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!