In order to display typeset mathematics and graphics, the server can generate images. These provide a simple way to view the results of computations. However, they suffer from the serious defect that they cannot be used by the client. They cannot be resized, drawn with different fonts, or viewed in some alternative way. It is also hard for a computer program to extract any meaning from an image. Alternatives to images exist. In the case of mathematics you can use MathML, for graphics you can use SVG, and the LiveGraphics3D applet can be deployed for three-dimensional graphics. These alternatives are not always the appropriate solution and, for this reason, functions for generating images are provided.
<img src="/webMathematica/MSP?MSPStoreID=MSPStore1042942578_0&MSPStoreType=image/gif" alt="Created by webMathematica"/>
The src attribute references the MSP servlet through a URL, which includes a parameter that gives the name of the file. The MSP servlet returns the contents of the file and periodically deletes old image files. The actual location in which image files are saved is a workspace directory provided by the servlet container.
An alternative way to generate images is to use the Mathematica command Export, available for use with the function MSPExportImage. This provides more features, such as transparent backgrounds, but takes longer to generate. MSPExportImage always makes use of the Mathematica front end.
MSPShow is an MSP function that returns an image; in addition MSPFormat may return an image. It should be noted that these work by returning a string that contains the necessary img tag to reference the image file that is stored on the server. An example is shown below.
Therefore, if the MSP function is followed by a semicolon ';', as shown below, the output is suppressed. The use of a semicolon to suppress output is discussed in Evaluation Formatting.
Another use of these functions is to embed their results into some other formatting function such as those in the HTML Package. The example below will return an HTML table with two images.
The LiveGraphics3D applet displays Mathematica three-dimensional graphics and provides support for features such as interactive rotation and resizing. A simple example that shows how to use MSPLive3D to embed a three-dimensional graphics object into a web page follows.