Hi, you either need a servlet request or servlet context, you can get a servlet context through the init method of a servlet or by registering a servlet context listener (assuming you use latest Sling which is using the http whiteboard). Other than those, I think there is no good way
Regards Carsten Roy Teeuwen wrote > Hey all, > > It seems I was able to fix it by using the sling request fro > ProcessingContext that is available in the TransformerFactory init method :). > But it would still be nice to know if it is possible to get the context path > without a sling request! > > Greets, > Roy > > >> On 9 Dec 2016, at 17:14, Roy Teeuwen <[email protected]> wrote: >> >> Hey all, >> >> I am trying to get the context path of the sling application somewhere where >> I don't have a HttpServletRequest at hand, so I cant call >> request.getContextPath(). >> >> More specifically I have a bug in a TransformerFactory that transforms links >> to versioned clientlibs (acs-aem-commons >> VersionedClientlibsTransformerFactory), but my application has a context >> path, so this doesn't work. >> I want to try and see if I can fix it myself and create a PR instead >> reporting a bug, but I'm a bit lost in how to get the context path. Anyone >> can help? >> >> Greets, >> Roy > > -- Carsten Ziegeler Adobe Research Switzerland [email protected]
