MathML Logo


#Call for Papers

#General Information

#Registration

#Accommodations

#Travel

#Tutorials

#Presentations

#Schedule

    

webMathematica: How to Deliver Computational and Visualization Services from a Web Server

Tom Wickham-Jones
Wolfram Research, Inc.


Abstract

webMathematica enables the creation of web sites that allow users to compute and visualize results directly from a web browser. This demonstration will show the basics of webMathematica and how to develop material for visualization and computation. It will also show how webMathematica can use MathML and work with other MathML tools.

webMathematica Technology

The web interaction of webMathematica is provided by a Java web technology called Java servlets. Servlets are special Java programs that run on a web server machine. Support is provided by a separate program called a servlet container (or sometimes a "servlet engine") that connects to the web server. One popular servlet container is Apache Tomcat, http://jakarta.apache.org/tomcat/, which is the reference implementation. Essentially all modern web servers support servlets natively or through a plug-in servlet container. This includes Apache, Microsoft's IIS and PWS, Netscape Enterprise Server, iPlanet, and application servers  (such as IBM WebSphere).  Closely related to Java servlets are Java Server Pages (JSPs) ; both servlets and JSPs integrate very closely with webMathematica.

The computation and visualization engine for webMathematica is Mathematica. Some of the useful features that make Mathematica powerful for use in web sites are: numerical and symbolic computation, visualization, programming, connectivity to other languages such as Java, the Mathematica notebook user interface (front end) and mathematical typesetting. The features of Mathematica are explored further on the Wolfram Research web site, http://www.wolfram.com.

Mathematica Server Pages

webMathematica is driven by a technology called Mathematica Server Pages. This involves inserting Mathematica commands into HTML pages, a form of HTML templating.  These pages, called MSP scripts, are easy to write and fit well with HTML development tools such as editors. Part of a sample MSP script is shown below.

    <form action="Expand" method="post">
      Enter a polynomial (eg x+y):
      <input type="text" name="expr" size="10">
      Enter a positive integer (eg 4):
      <input type="text" name="num" size="3">
      <br/>
      
      <%Mathlet
             MSPBlock[{$$expr,$$num},
                     Expand[$$expr^$$num]] %>
                     
      <br/>
      <input type="submit" name="button" value="Evaluate">
    </form>

This is all HTML except for the Mathlet tag. Its contents are computed by Mathematica on the server and the result inserted into the page. The generated page is then returned to the browser.

There are many Mathematica commands for working with web requests and responses. Support is built in for plotting, formatting and typesetting, embedding applets, and returning general content. In the example above, the command MSPBlock, takes care of converting the input variables $$expr and $$num, to Mathematica input (applying a security system) and then evaluating the Expand command. In general the results of a webMathematica server can be any format that Mathematica supports, this includes images, XML, MathML, and Mathematica notebook documents. An example of webMathematica generating Mathematica notebooks is found at http://library.wolfram.com/webMathematica/MSP/Explore/Graphics/Polyhedron.

An example of a webMathematica page is shown below. Here, the user enters some parameters and clicks on the visualize button. The request is sent to the webMathematica server which calls Mathematica to solve the problem and generate a visualization of the result. The server returns a web page that displays the image.

[Graphics:Images/index_gr_1.gif]

This and further examples of webMathematica are available at the Wolfram Research web site
http://www.wolfram.com/products/webmathematica/examples.

Extending webMathematica

webMathematica can work with different client technologies, such as JavaScript, Java applets, Active-X controls, browser plug-ins, and Microsoft Excel™. One important example involves the use of webMathematica with MathML rendering technology; this is described in the next section.

webMathematica also integrates very conveniently with its underlying Java web technology. As a consequence, many important features are readily available to webMathematica. Examples include, HTTP session support, file upload, database connectivity, XML integration, load balancing and automatic failover.

webMathematica and MathML

webMathematica and MathML are both highly relevant to the provision of math services on the web. webMathematica offers a mechanism to construct web sites for mathematical computation. MathML, as a language supporting the use and re-use of mathematical and scientific content, is very suitable to be used as an interchange format between different systems. An interchange format is very necessary since the web is a distributed environment that may involve a number of different applications. An example of this is a webMathematica server using MathML to work with other MathML-aware applications.

webMathematica contains a number of features for working with MathML. These use the tools that are part of Mathematica for working with MathML, supporting the use of MathML both for output and for input. The demonstration will show the use of webMathematica with various client side MathML tools. The example below shows a webMathematica server formatting the result of a computation into MathML. The MathML is then sent to the browser where it is rendered with MathPlayer, a MathML display engine.

[Graphics:Images/index_gr_2.gif]


When viewing this example, it should be noted that webMathematica and MathPlayer are independently developed software applications that can work together using MathML. The example makes use of some of the webMathematica utility functions for working with MathML. An example of a Mathlet that makes use of these commands formatting an expression into MathML is shown below.

<%Mathlet
    MSPBlock[{$$fun},
        MSPFormat[ Integrate[$$fun, x], TraditionalForm, RawMathML]] %>

Important Features

Some of the important features of webMathematica are described here.

webMathematica is server based as opposed to being client based. It is typically easier to control the environment of a server than it is of the clients that connect to the server. Computing on the server means that there is no need to deliver large libraries of software to run on the clients, and updates and bug fixes are easier to arrange. Many of the current web examples for mathematical and scientific computation use client techniques, for example applets; it is less common to find server computation such as provided by web Mathematica.

There are a number of software implementations that support MathML, a listing is found at http://www.w3.org/Math/implementations.html. These tools include browsers and applications that offer important features such as rendering, conversion or interactive editing. Many could certainly be useful in a web server environment, for example, generating MathML that could be deployed on a server. However, of these MathML tools only webMathematica is a server technology plugging directly into a web server.

webMathematica offers an HTML templating mechanism that makes it particularly easy to develop webMathematica content. One important benefit of HTML templating is that the visual appearance of web pages and computational content can be separated.

webMathematica  is integrated with standard Java web technology. This allows web sites that use servlets or JSPs very convenient access to webMathematica and many of their important features can be used in webMathematica.

webMathematica can generate results of many different formats in addition to HTML. One important use of this is for webMathematica to generate a document format, such as PDF or Mathematica notebooks.