Going to webpage using a combination of ScriptEngine and JavaScript
<p>I'm trying to go to a webpage using Javascript and ScriptEngine from Java. I did something like this for testing:</p>

<pre><code>    ScriptEngineManager factory = new ScriptEngineManager();
    ScriptEngine engine = factory.getEngineByName("JavaScript");

    StringWriter result = new StringWriter();
    PrintWriter printResult = new PrintWriter(result);

    engine.getContext().setWriter(printResult);
    try {
        engine.eval("self.location = \"wwww.yahoo.com\"");
    } catch (ScriptException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
</code></pre>

<p>But when I run this I get </p>

<pre><code>javax.script.ScriptException: sun.org.mozilla.javascript.internal.EcmaError: 
   ReferenceError: "self" is not defined. (&lt;Unknown source&gt;#1) 
   in &lt;Unknown source&gt; at line number 1.
</code></pre>

<p>The idea is that the target website(Not yahoo by the way. I just used it for testing) doesn't seem to respond to HTTP post requests normally due to its framework so I would like to use Javascript to try to send my post requests. Is my idea actually possible on ScriptEngine or do I have to use something else entirely?</p>
