I am trying to use rhino. I want to use window.atob(param)
javascript function from java code. First of all is it possible? This is what I have tried.
ScriptEngine runtime = null;
try {
runtime = new ScriptEngineManager().getEngineByName("javascript");
runtime.put(
"str",
"PGh0bJvZHk+PC9odG1sPg==");
System.out.println((String)runtime.eval("window.atob(str)"));
} catch (Exception ex) {
ex.printStackTrace();
}
I am getting the following exception.
sun.org.mozilla.javascript.internal.EcmaError: ReferenceError: "window" is not defined
I know I can decode using java but can any one let me know how to do it using rhino?