The question is in the title - how to obtain the ServletContext
in Config.groovy
. The purpose is to get the real (absolute) path of the current context.
views:
33answers:
1
A:
It's not possible to get the ServletContext
there.
It is possible to get the absolute path via an ugly workaround:
def path = getClass().getProtectionDomain().getCodeSource().getLocation()
.getFile().replace(getClass().getSimpleName() + ".class", "").substring(1);
(the substring(1)
removes an unnecessary leading slash)
Bozho
2010-09-17 12:56:44