tags:

views:

33

answers:

1

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.

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