I figured out a solution to this, not entirely sure if it's the preferred way or a best practice.
I was able to inject a javax.servlet.ServletContext object onto my DeclaritiveWebScript by having it implement ServletContextAware. Here's the code:
Code:
public class ProductDetailsController extends DeclarativeWebScript implements ServletContextAware {
private ServletContext sc;
@Override
public Map<String, Object> executeImpl(WebScriptRequest req, Status status, Cache cache) {
System.out.println("Injected ServletContext: ["+sc+"]");
}
@Override
public void setServletContext(ServletContext sc) {
this.sc = sc;
}
}