• 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

web application - property file

 
Ranch Hand
Posts: 30
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to read all the properties from an application property file into a java class which is part of a web application deployed on weblogic. I am currently hardcoding the location of the property file which holds parameters necessary for my application like email id of the application administrator etc. I use these properties in some of my classes which implement business logic. If I am using parameters in a servlet, I can get it via the init() method from web.xml. But how do I retrieve parameters which are not used in a servlet without hardcoding the location of the file which holds these parameters. Is there a better way to obtain the location of this property file.
 
Author
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Everything in your web application should be able to get at the ServletContext object, so you can always try to encode information in the web.xml parameters. Or alternatively, you can use the ServletContext object to resolve the location of a file in your web application, e.g. your property file.
However, if you want to use regular Java property files you can as well. Simply put the '.properties' file in your WEB-INF/classes directory of your web application. It will then be in the class path of your application.
 
That is a really big piece of pie for such a tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic