• 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

Loading a properties file from the bean

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have to load a properties file from a bean.This bean is called from the jsp page.
The properties file is in the same folder as the jsp page.But how do I get the correct path in the bean to load the property file.
If I call the System.getProperty("user.dir"), it gives me the path to the folder before the jsp page.(Not the one where the jsp and the property file is).My jsp lies in the following path -
c:\\prgram files\allaire\JRun\servers\default\time
and the path returned by System.get...
is
c:\\program files\JRun\servers\default
.
I don't want to add the folder Time to the path in the code b'coz it may change in different environments.
(This is in extension with my earlier mail.Though the complete problem is detailed out here.)
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

U can put the properties file in classpath
and read using System.getProperty("java.class.path").
chin
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you put the properties file on the class apth then it's actually easier than that:
Drop it on the class path, use ClassLoader.findResource to get a handle on the file (via a URL) then open an InputStream and read it.

Dave.
 
When I was younger I felt like a man trapped inside a woman’s body. Then I was born. My twin is 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