Mathematica Web Functions

webMathematica contains a large number of Mathematica commands that can be used inside the webMathematica tags that provide useful functionality for creating web material with Mathematica. These are useful in various ways such as processing request parameters that are the input from a web user, formatting results, and using web features such as uploading files and HTTP sessions.

Typically, these commands are used inside of an evaluate tag; more information on these tags is found in the webMathematica tags section. An example, which calculates an integral and uses the function MSPFormat to format the result into TraditionalForm, is shown below.

MSPFormat[ Integrate[ expr, {var, 0, Infinity}], TraditionalForm]

The different functions are shown in the following sections.

Processing Input

HTTP input variables are a key way to control the operation of a dynamic website. These are typically embedded in your input page with <input> tags. webMathematica provides a number of functions for working with and processing input. This needs to be done carefully to avoid any security problems. The functions are summarized in the following table.

MSPBlocksecure scoping construct for HTTP input
MSPToExpressioninterpret input in a secure way
MSPValuereturn the value of an HTTP input variable
MSPValueQtest if an HTTP input variable has a value


webMathematica provides a number of important ways to format output for finished web pages. These include formatting into text, HTML, GIF, XML, MathML, and other formats. These are summarized in the following table.

MSPFormatformat results into text or image formats
MSPShowformat graphics by creating an image
MSPLive3Dformat 3D graphics to allow interactive viewing
MSPGetMessagesdisplay any messages
MSPGetPrintOutputdisplay any print output
HTMLTableFormformat into an HTML table
HTMLSelectformat into an HTML select

Web Interaction

webMathematica provides a number of key functions for working with web features such as HTTP sessions and file upload. These are summarized in the following table.

MSPReturnhalt processing of the current page and return a different result
MSPSessionVariablescope a variable to an HTTP session
MSPGetUploadFileget the name of a file uploaded with the HTTP request
MSPURLStorestore a result on the server that can be retrieved with a URL