File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What should System.getProperty("user.dir") return when called from a bean ?

 
Celina Joseph
Greenhorn
Posts: 24
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay now, lemme explain the real problem.
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 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.
I have a jsp which is in directory c:\\...default\ccsd.
From this jsp, I call a bean interface which returns the System.getProperty("user.dir").
The returned value is - c:\\....\default instead of c:\\...\default\ccsd.
I cannot understand the logic behind it.
JRun 3.0 is being used.

[This message has been edited by Celina Joseph (edited August 30, 2001).]
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

ummm....that probably the root dir of your web application.
haven't tried it, so partly guessing...
Am I right?
Please let me know what the root of your application is....
just curious...
regds.
- satya
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
38
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I wouldn't even try it. In fact, I think a lot of systems will return a null object, depending on how the server was started and the rest would return something unique to the server - and it MIGHT even change unpredictably as the server processes different requests.
It's not really appropriate here. You're better off starting from a known absolute reference point, which you can pass in as a server parameter.
 
Madhav Lakkapragada
Ranch Hand
Posts: 5040
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

sounds really scary to even attempt.....
- satya
 
Tim Holloway
Saloon Keeper
Pie
Posts: 17616
38
Android Eclipse IDE Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Y'know, on reflection, there's a larger issue here. You really shouldn't put control information in a location from which content can be served. Bad Guys like to dig around the normal access mechanisms and abuse your hard work.
If you put the properties file in the classes directory you can use the java Resource functionality to access it without having to know its absolute location.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic