Functional Area : JUSP: Server-Side Scripting

JudoScript can be used to produce dynamica web pages just like JSP or ASP; the mechanism is called JUSP (pronounced /ju:sp/). A JUSP page is a HTML template with embedded JudoScript code; a block of code is enclosed in <% and %> ; an expression is enclosed in <%= and %> ; and and enclose comments that become JudoScript comments and not shown in the generated HTML.

The JUSP engine is the servlet com.judoscript.jusp.JuspServlet. It must be configured with an init-parameter juspRoot that points to the root of all JUSP pages. Within a JUSP page, these variables are predefined:

In addition, the following are predefined:
const #Cookie = javaclass javax.servlet.http.Cookie;

JUSP pages can include other JUSP pages via the directive. The extra in the otherwise ordinary directive tells to preprocess the included file as JUSP.

Java GUI programs are essentially made of two parts: assembly of GUI components and event handling. Using 's Java scripting capability, assembling AWT and Swing components is easy. uses a special to handle GUI events. This statement can specify event handlers for individual components or a group of components. In the latter case, a named handler is created, which is used by to assign to specific components. Different 's can be used for different sets of components.

For a javax.swing.Timer object, the event handler is specified the same was as other GUI components. The Timer constructor takes a java.awt.event.ActionListener instance; in this is obtained by . What really happens is, a GUI program has just one java.awt.event.ActionListener object, and it routes all the GUI events to the respective handler code written in . returns just that ActionListener object.

The language engine takes source files of Java, C and C++, filters out code encoded in and and runs it. This is useful for unit testing of that source file, or other purposes.

language engine has an interface that allows itself to be embedded in other Java software; its LGPL licencing helps, too;) Alternatively, Java software can use the Bean-Scripting Framework (BSF), a standard API for scripting languages to interact with Java software. You can construct program text on-the-fly and execute it, and pass objects between and Java back and forth.

's Bean Scripting Framework (BSF) engine is implemented by class com.judoscript.BSFJudoEngine.

The following table summarises using BSF.

CategoryDescription
Language identifierjudoscript
File extension(s).judo, .jud
Look up a bean$$bsf.lookupBean("name-of-bean")
Create a new beanJudoScript's javanew operator
Register a bean$$bsf.registerBean("name-of-bean",$bean)
Unregister a bean$$bsf.unregisterBean("name-of-bean")
Bind a script to be executed upon event firingJudoScript's guiEvent{} or adapter
Do all bean operationsJudoScript method call
Language homehttp://www.judoscript.com

With the ability to , can be used in your applications. Here are a few hints for embedding .

The recommended way to build library for is actually to write Java, not only for performance but also for reusability across Java and code. This does not exclude building libraries of functions and classes; in fact, such libraries ( source files) can be put anywhere in the CLASSPATH.

has a few mechanisms to make using your Java code even easier. One is the to make Java static methods look like regular functions, the other is to make using your Java classes easier (without having to worry about long Java class names.)

myjsysfxns.properties and myjavapkgs.properties

A large portion of system functions are actually implemented by static Java methods; they are listed in com/judoscript/jsysfxns.properties. You can extend this system function list by creating a similar properties file and name it as com/judoscript/myjsysfxns.properties. Since this properties file does not exist in the standard distribution, your changes will not be overwritten by version upgrades. Another properties file, com/judoscript/javapkgs.properties, holds the predefined Java package shortcuts. You can create your predefined Java package shortcuts in com/judoscript/myjavapkgs.properties.

In the script, anything starting on the next line of can be accessed via a predefined input stream. Anything on the rest of the line containing of is discarded. wt.event.ActionListener object, and it routes all the GUI events to the respective handler code written in . returns just that ActionListener object.

The language engine takes source files of Java, C and C++, filters out code encoded in and and runs it. This is useful for unit testing of that source file, or other purposes.

language engine has an interface that allows itself to be embedded in other Java software; its LGPL licencing helps, too;) Alternatively, Java software can use the Bean-Scripting Framework (BSF), a standard API for scripting languages to interact with Java software. You can construct program text on-the-fly and execute it, and pass objects between and Java back and forth.