Bean Scripting Sample

Run Javascript on the Application Server! With support for IBM's Bean Scripting Framework, the Application Server can now process both Java and Javascript in JavaServer Pages (JSPs). This sample has two JSPs that convert Fahrenheit to Centigrade; one page has a JSP scriptlet coded in Java and the other page has a JSP scriptlet coded in Javascript. Run them to see the results. View the source to compare the code.

Run the Java version
Run the Javascript version


How this sample works:

This sample has:

The Application Server converts a JSP into Java, then compiles and executes it before returning the results to the browser. Therefore, Java is the default scripting language for JSPs. IBM's Bean Scripting Framework translates Javascript contained in a JSP scriptlet into Java and allows the Application Server to compile and execute it as part of the JSP.


How to use this sample on your web page:

Add a link from your HTML page to the JSP page. When you put script in your JSP, include the JSP tag that informs the Application Server which scripting language you will use:

  • To use Java: <jsp:directive.page language="java"/>
  • To use Javascript: <jsp:directive.page language="javascript"/>