public void generateResponse(StaplerRequest req, StaplerResponse rsp, Object node) throws IOException, ServletException {
try {
new DefaultScriptInvoker() {
@Override
protected JellyContext createContext(StaplerRequest req, StaplerResponse rsp, Script script, Object it) {
JellyContext context = super.createContext(req, rsp, script, it);
for (int i=bodyStack.length-1; i>0; i--) {// exclude bodyStack[0]
context = new JellyContext(context);
context.setVariable("org.apache.commons.jelly.body",bodyStack[i]);
}
return context;
}
@Override
protected void exportVariables(StaplerRequest req, StaplerResponse rsp, Script script, Object it, JellyContext context) {
super.exportVariables(req, rsp, script, it, context);
context.setVariables(variables);
req.setAttribute("currentDescriptorByNameUrl",currentDescriptorByNameUrl);
}
}.invokeScript(req,rsp,bodyStack[0],null);
} catch (JellyTagException e) {
LOGGER.log(Level.WARNING, "Failed to evaluate the template closure", e);