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

Documentation6. Advanced Topics


6.4 Processing a JSP

This section will describe the different stages that are involved in processing a JSP for webMathematica.

A JSP is processed as part of an HTTP transaction. A client sends a request to the server, which replies with a response. One feature of HTTP requests is that they can send parameters and values to the server. This is essential for any dynamic behavior, because parameters are used to select and control the response. The response could be an HTML page. However, it could be some other content type, such as an image, a Mathematica notebook, or some form of XML.

The JSP is processed by the servlet container in which it is running, it is processed in a top-down method, so that commands at the top are evaluated before commands lower down. A JSP interacts with webMathematica by means of the custom tags defined in the MSP Taglib. A sample page is shown below.

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

The <msp:allocateKernel> tag takes responsibility for allocating a Mathematica Kernel to use for computations, assigning input variables and parameters, and other initialization. Note that the Kernel that was allocated will be available in a clean state. A later section describes the details of <msp:allocateKernel>.

Any <msp:evaluate> tags then use the allocated Mathematica Kernel to evaluate their input. Note that any assignments or definitions made in one <msp:evaluate> tag will be visible in another. A later section describes the details of <msp:evaluate>.

Finally the </msp:allocateKernel> tag takes responsibility for releasing the Mathematica Kernel, first cleaning it of any definitions that were made. If any special processing, for example to deal with exceptions, is needed this will be carried out at this point. A later section describes the details of </msp:allocateKernel>.

It should be noted that there are a number of other special tags that can be used, these are detailed in the section on the MSP Taglib.