tags:

views:

22

answers:

1

Hi,

Is there a variable where we can find out the root directory of my Grails application?

I tried request.getSession().getServletContext().getRealPath("/") But shows tmp/App-Test-0.1/ .

My app is located in tomcat "/home/srinath/work/projects/tomcat-6.0.18/webapps/App-Test-0.1"

could any one help me .

thanks in advance, sri..

A: 

Hi

MainContext:

import org.codehaus.groovy.grails.commons.ApplicationHolder;
ApplicationContext ctx = (ApplicationContext)ApplicationHolder.getApplication().getMainContext();

Example:

ApplicationHolder.getApplication().getMainContext().getResource("/").getFile().getAbsolutePath()
Tom