The last time I tried, although ScriptEngine is whitelisted, it is not available in the production environment. I had to pack Rhino.jar along with my application.
In examples of common use of scripts in Java, you can directly refer to the Java documentation .
Although, note that in a GAE / J environment, you will need to directly access the Rhino APIs.
For instance,
// Import statements. import org.mozilla.javascript.Context; import org.mozilla.javascript.Scriptable; private Object executeUsingRhino(String script) throws Exception { Context ctx = Context.enter(); try { Scriptable scope = ctx.initStandardObjects(); return ctx.evaluateString(scope, script, "<cmd>", 1, null); } finally { Context.exit(); } } // Invoke a script that returns a string output using the following code snippet String output = Context.toString(executeUsingRhino(script));
source share