Reputation: 3812
I have an ajax file upload system up and running.
What I'm trying to do is store the files in a directory under Apache's webroot, the app is running in tomcat and I'd prefer storing the files outside of the webroot (in tomcat), and inside the webroot of Apache somewhere, as we regulary update the app.
I've got this:
var root = new java.io.File("").getAbsolutePath()
Which can give me the apps location.
I really don't want to have to add this to a config.xml for the app, so I was wondering if anyone out there knew how to find the location of Apache's webroot in the event it changes or we swap servers and the setup is different?
Wow I typed "webroot" alot..
Thanks alot for any help, much appreciated :)
Upvotes: 1
Views: 151
Reputation: 8601
Finding the current apache location is a tricky business, specially if you need to deal with virtual hosts. You should probably be using property files for that. You can have multiple Props files, one for each environment.
Lift has many ways to load the property files, I highly recommend finding a solution using it. For instance, you can even override where to look for a config file in Lift.
Alternatively, you can have the apache home set as a variable in the jetty startup script, something like:
JAVA_OPTIONS="$JAVA_OPTIONS -Dapache.home=/etc/httpd"
And then use it in your code:
val apacheHome = System.getProperty("apache.home")
Beware that System.getProperty returns null if such property does not exists. You might want to use Option
, making the check more idiomatic:
val apacheHome = Option(System.getProperty("apache.home"))
// apacheHome: Option[java.lang.String] = ...
Upvotes: 1