How a servlet can get the absolute path to a file outside of the servlet?

Posted by WolfmanDragon on Stack Overflow See other posts from Stack Overflow or by WolfmanDragon
Published on 2009-02-17T20:06:14Z Indexed on 2010/04/05 7:03 UTC
Read the original article Hit count: 288

Filed under:
|
|
|
|

We have been using System.getProperties("user.dir") to get the location of a properties file. Now that it has been deployed on Tomcat(via servlet), the System call is giving the location as tomcat and not at the location at where the properties file exist.

How can we call the the properties file dynamically?

Given:

  • Tomcat is not the only way the app will be deployed
  • We have no control on where the app may be placed.
  • Relative paths will not work as that Vista is being used and Vista breaks relative paths.
  • This must work on all OS, including(but not limited to) Linux, XP and Vista.
  • EDIT I implied this, but in case I was not clear enough, I have no way of knowing the path String.

© Stack Overflow or respective owner

Related posts about java

Related posts about tomcat