• 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

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

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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).]
 
Ranch Hand
Posts: 5040
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

sounds really scary to even attempt.....
- satya
 
Tim Holloway
Saloon Keeper
Posts: 27808
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
reply
    Bookmark Topic Watch Topic
  • New Topic