7 Replies Latest reply: Dec 14, 2010 11:40 PM by 823735 RSS

    EvaluatorException while evaluating string having ' using ScriptEngine

    823735
      ScriptEngineManager engineMgr = new ScriptEngineManager();
                ScriptEngine engine = engineMgr.getEngineByName("JavaScript");
                try {
                     engine.eval("*arc.i'rick@hello.co.uk*");
                } catch (ScriptException e) {
                     // TODO Auto-generated catch block
                     e.printStackTrace();
                }

      Above is my code, I have given ' (apostope) in email id and it's giving me below exception

      javax.script.ScriptException: sun.org.mozilla.javascript.internal.EvaluatorException: unterminated string literal (<Unknown source>#1) in <Unknown source> at line number 1
           at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:110)
           at com.sun.script.javascript.RhinoScriptEngine.eval(RhinoScriptEngine.java:124)
           at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:247)
           at com.ideas.px.user.Test1.main(Test1.java:17)

      please suggest how to escape this?