Say I have some javascript that if run in a browser would be typed like this...
<script type="text/javascript"
src="http://someplace.net/stuff.ashx"></script>
<script type="text/javascript">
var stuff = null;
stuff = new TheStuff('myStuff');
</script>
... and I want to use the javax.script package in java 1.6 to run this code within a jvm (not within an applet) and get the stuff. How do I let the engine know the source of the classes to be constructed is found within the remote .ashx file?
For instance, I know to write the java code as...
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine engine = mgr.getEngineByName("JavaScript");
engine.eval( "stuff = new TheStuff('myStuff');" );
Object obj = engine.get("stuff");
...but the "JavaScript" engine doesn't know anything by default about the TheStuff class because that information is in the remote .ashx file. Can I make it look to the above src string for this?