56
<%@ page language="java" %>
<%@ taglib uri="/webMathematica taglib" prefix="msp" %>
Set Example
Set Example
This jsp uses the MSP Taglib to demonstrate passing
Java values to Mathematica.
<%
int num = 10;
Object obj = new Object();
%>
Nest[ f, x, var1]
Characters[ var2]
var3@hashCode[]
In this example, a variable num, which is an int, str, which is a String, and obj, which is an Object, are created in
the JSP. These are then passed to Mathematica using the msp:set tag. This tag takes two attributes, the name
attribute gives the name that the variable will be given in Mathematica, while the value attribute refers to the
value. If the variable is of a primitive type, such as int, char, or double, then it needs to use the appropriate value
attribute, such as intValue, charValue, or doubleValue. Notice how msp:set sends a Java int as a
Mathematica integer and a Java String as a Mathematica string. The Java Object is sent as a Mathematica object
reference. The rules that govern how types are sent from Java to Mathematica are exactly those that J/Link uses.
.
<
New Page 1
Comcast Web Hosting