i'm trying to call document in java using scriptEngine here is my code
ScriptEngineManager scriptEngineManager=new ScriptEngineManager();
ScriptEngine scriptEngine=scriptEngineManager.getEngineByName("nashorn");
scriptEngine.eval("function func(){" +
"document.location.href=someUrl;" +
"var text=document.getElementsByTagName('textarea')[0];"}"
);
Invocable invocable= (Invocable) scriptEngine;
((Invocable) scriptEngine).invokeFunction("func");
it throws an exception
javax.script.ScriptException: ReferenceError: "document" is not defined in <eval> at line number 1