JMeterContext jmctx = JMeterContextService.getContext();
JMeterVariables vars = jmctx.getVariables();
mgr.declareBean("ctx", jmctx, jmctx.getClass()); // $NON-NLS-1$
mgr.declareBean("vars", vars, vars.getClass()); // $NON-NLS-1$
BSFEngine bsfEngine = mgr.loadScriptingEngine(getScriptLanguage());
Object bsfOut = null;
if (fileName.length()>0) {
res.setSamplerData("File: "+fileName);
is = new FileInputStream(fileName);
bsfOut = bsfEngine.eval(fileName, 0, 0, IOUtils.toString(is));
} else {
res.setSamplerData("[script]");
bsfOut = bsfEngine.eval("script", 0, 0, request);
}
if (bsfOut != null) {
res.setResponseData(bsfOut.toString().getBytes());
}