/** Execute supplied code against supplied data,
* see JavascriptEngineTest for examples */
public String execute(String code, String jsonData) throws IOException {
final String jsCode = "data=" + jsonData + ";\n" + code;
final Context rhinoContext = Context.enter();
final ScriptableObject scope = rhinoContext.initStandardObjects();
// execute the script, out script variable maps to sw
final StringWriter sw = new StringWriter();
final PrintWriter pw = new PrintWriter(sw, true);
ScriptableObject.putProperty(scope, "out", Context.javaToJS(pw, scope));