ATG - How to access deployed files from a GenericService based service? -
i have service (subclass of genericservice) needs find path deploy directory [under application server's install directory] @ run-time without hard-coding it; path varies between many environments in work on daily basis.
i found how within jsp file, following gives need, cannot find serveletcontext:
servletcontext context = session.getservletcontext(); string path = context.getrealpath("/my/path");
however, don't have request or session objects in service, or i? i've been looking at
getadminservlet().getservletconfig().getservletcontext().getrealpath("/my/path");
but i'm not getting context back.
we using atg 9.1 on jboss 4.2.
i appreciate assistance.
any service implements genericservice
have access getnucleus()
in turn gives access getrealpath(string str)
.
as i'm not sure why need use context.getrealpath(string str)
should note there occasions may not best suited needs. for example won't able access if deploy application in .war.
that said, may simpler approach doesn't care environment deploy to:
private string getbasepath() { string basepath = dynamoenv.getproperty("atg.dynamo.server.home"); return basepath; }
it environment agnostic , since can't run atg without home folder... should work wonders.
Comments
Post a Comment