Hi,
after figuring out yesterday how to configure my Eclipse project to be able to run JS code (if your interested: http://stackoverflow.com/questions/3417958/), I have the next question related to this topic: I got a JS file and a function within it. I need to run that function inside my Java code and to pass a (Java string) variable in it. My file is very basic, it currently looks like this:
public class Com_feedic_readabilityServlet extends HttpServlet {
public void doGet(HttpServletRequest req, HttpServletResponse resp)
throws IOException {
resp.setContentType("text/html");
Context cx = ContextFactory.getGlobal().enterContext();
cx.setOptimizationLevel(-1);
cx.setLanguageVersion(Context.VERSION_1_5);
Global global = Main.getGlobal();
global.init(cx);
Main.processSource(cx, "server_js/js_init.js");
}
}
What I need to do now is calling the function run()
within the js_init.js
-file. How do I manage that?