Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading a properties file from the bean

 
Celina Joseph
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • 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.)
 
chin josei
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

U can put the properties file in classpath
and read using System.getProperty("java.class.path").
chin
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic