}
String path = (String) script;
path = path.startsWith("/") ? path : "/" + path;
Stack<String> callstack = CommonManager.getCallstack(sharedContext);
callstack.push(path);
engine.exec(new ScriptReader(servletContext.getResourceAsStream(path)) {
@Override
protected void build() throws IOException {
try {
sourceReader = new StringReader(HostObjectUtil.streamToString(sourceIn));
} catch (ScriptException e) {
throw new IOException(e);
}
}
}, sharedScope, null);
callstack.pop();
}
}
}
}
Object serveFunction = request.getServletContext().getAttribute(SERVE_FUNCTION_JAGGERY);
if (serveFunction != null) {
Function function = (Function) serveFunction;
ScriptableObject scope = context.getScope();
function.call(cx, scope, scope, new Object[]{
scope.get("request", scope),
scope.get("response", scope),
scope.get("session", scope)
});
} else {
//resource rendering model proceeding
sourceIn = request.getServletContext().getResourceAsStream(scriptPath);
if (sourceIn == null) {
response.sendError(HttpServletResponse.SC_NOT_FOUND, request.getRequestURI());
return;
}
CommonManager.getInstance().getEngine()
.exec(new ScriptReader(sourceIn), context.getScope(),
getScriptCachingContext(request, scriptPath));
}
} catch (ScriptException e) {
String msg = e.getMessage();
log.error(msg, e);