It may not be practical, but for me it is a task. I have an open ServerSocket in java. Now I want to read a file containing html and javascript and output the javascript result to the browser. So I would appreciate server side javascript. So I want what's inside for an assessment.
I tried to check it, it worked, but it has some problems, for example, it prints a message in System.out. And engine.eval ("print ('Welocme to java worldddd')"); doesn't return a string so that I can output it to the socket output stream:
import javax.script.*;
ScriptEngineManager factory = new ScriptEngineManager();
ScriptEngine engine = factory.getEngineByName("JavaScript");
try {
engine.eval("print('Welocme to java worldddd')");
} catch (ScriptException ex) {
Logger.getLogger(doComms.class.getName()).log(Level.SEVERE, null, ex);
}
source
share