javax.script

Using the javax.script package for javascript with an external src attribute

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"&gt;&lt;/script&gt; <script type="text/javascript"> var stuff = null; stuff = new TheStuff('myStuff'); </script> ... and I want to use the javax.script package in ja...

Can I create a 'window' object for javascript running in the Java6 Rhino Script Engine

I want to run some Javascript on my Java6 server - i.e. using the javax.script API, specifically the Rhino Script Engine. (Although another solution would be acceptable) The script file is created & supported by a third party, so I don't want to download it and edit it in case it changes over time. The script directly references the 'w...

How do I secure scripts run using javax.scripting?

I am using javax.scripting to add support for running arbitrary user-uploaded JavaScripts on the server-side. Obviously I want to secure those scripts! Rhino, on it's own, has a framework for securing scripts at runtime. The documentation for javax.scripting, however, doesn't mention security, permissions or restricting classes availa...

Java 6: Examples for implementing own scripting language using javax.script?

Hello! I really can't find good examples for implementing own scripting language using javax.script ... I need just something to start. Documentations Examples Tutorials Videos Presentations slides (PDF) Note 1: I'm really not talking about javascript ;) Note 2: I don't need examples, how to use existing implementations, I want to ...

Loading a javascript library in javax.script?

I want to run Protovis javascript from Java and get the evaluated SVG code. I am using javax.script.* to run the Javascript: public static void EvalScript() throws Exception { ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); Object result = engine.eval("va...

Using javax.script or Rhino to run javascript in Java with browser context (e.g. envjs)?

I am trying to run Protovis javascript from a Java program using javax.script: ScriptEngineManager factory = new ScriptEngineManager(); ScriptEngine engine = factory.getEngineByName("JavaScript"); engine.eval(new java.io.FileReader("protovis-d3.1.js")); In order to run this, the JavaScript engine needs to have all the context of a web...

Calling Python from Java through scripting engine (jython)?

I'm trying to call Jython from a Java 6 application using javax.script: import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class jythonEx { public static void main (String args[]) throws ScriptException { ScriptEngineManager mgr = new ScriptEngineManage...

javax script how to call a function in JavaScript from Java

Hi All, I'm trying to call a function in JavaScript via Java. This works fine when directly reading a script as a string but I'm using CompiledScripts. When I do this with a compiled script it gives me method not found if I also add bindings. Without bindings it works but of course the function fails because it needs the bindings. ...

How can I specify my own Rhino context in Java?

I'm trying to ensure that my Rhino scripts (running under Java 6) are strict so that if a script developer misspells an expression I want an exception to be thrown. Currently what happens is the expression simply evaluates to "undefined". Now according to Mozilla org https://developer.mozilla.org/en/New_in_Rhino_1.6R6 there are feature...

javax.script : Creating a class in a script or loading it from another file

Hello, In my script, I want to create a class or load it from an other file. How to do please ?? ...

Import a class in Scripting java (javax.script)

Hello, I want to import a class that I made in my project, into my script I did this but it doesn't work: function doFunction(){ //Objectif Mensuel importPackage(java.lang); importClass(KPDataModel.KPData.KPItem); //ERROR HERE, this is my class that I want to import KPItem kpItem = kpItemList.get(0); System.out.println(kpItem....

Rhino load() function available in JavaScript provided by javax.script?

Some JavaScript files that have been developed for Rhino's shell use load() to load additional JavaScript files. I'm attempting to embed functionality from one of these Rhino JavaScript files using javax.script. Unfortunately, the load() function is not implemented by javax.script's JavaScript. When attempting to eval() a script containi...

sqlite3 module for Jython

I'm using Java Scripting API to execute some external Python scripts from my Java application. The python scripts use sqlite3 module. Execution of the application is resulting in error ImportError: No module named sqlite3 As I look into the Lib directory(which is in the classpath) of Jython, there's no sqlite3 module. Hence, my search...