This is documentation for an earlier version of webMathematica.
View current User Guide (Version 3.3)

Documentation3. Basic Examples


3.1 Hello.jsp

If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Hello.jsp. (You may have some other URL for accessing your server.)

This example evaluates the Date[] function of Mathematica. The result changes each time the page is accessed, demonstrating that this really is a dynamic process. The source for this page is in webMathematica/Examples/Hello.jsp.

<%@ page language="java" %>
<%@ taglib uri="/webMathematica-taglib" prefix="msp" %>   standard jsp

<html>                              standard html tags
      <title>Hello World (The MSP Taglib)</title>
      <h1>Hello World (The MSP Taglib)</h1>
      <msp:allocateKernel>            allocate a Mathematica kernel
      Date::usage                     evaluated by Mathematica

      <p>Its current value is:</p>
          Date[]                     evaluated by Mathematica
      </msp:allocateKernel>            free the Mathematica kernel

This page uses standard HTML tags as well as special webMathematica tags; these have the form <msp:tag>. The webMathematica tags are executed from the top of the page to the bottom. The <msp:allocate> tag causes a Mathematica kernel to be allocated to use for computations. The contents of the <msp:evaluate> tags are sent to Mathematica for computation with the result inserted into the final page. The </msp:allocate> tag frees the Mathematica kernel to be used for another computation.