Is there a variable where I can find out the root directory of my Grails application?
for example, I have a folder named chart
under \%root%\web-app\images\
where I put my charts in. Once I deploy my Grails application on Jetty, I will get FileNotFoundException
because the root path becomes /srv/www/vhosts/domain-name/jetty-version/
I would like to know if there is a variable that returns the root path (like /srv/www/vhosts/domain-name/jetty-version/webapps/myapp
), and there should be because CSS uses relative path just fine.
solved.
request.getSession().getServletContext().getRealPath("/")
this actually gives me the path to where my application puts the images, css, WEB-INF, etc. folders.
System.properties['base.dir']
I know it is an old question, but this could work if you are not in an http request:
ServletContextHolder.servletContext.getRealPath('/')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With