webMathematica >

Returning General Content

Direct Return

MSPReturn

When an MSP script evaluates MSPReturn, the processing of the script is terminated and the first argument is immediately returned. The second argument specifies the content type. In this example a notebook object is returned, and the result is set to be application/mathematica.
However, for some HTTP clients (for example Internet Explorer) this has the undesirable effect of causing the client to display two Open or Save dialog boxes. Most clients work much better if the request for the script that contains the MSPReturn uses the filename with an appropriate extension. Since the extension for webMathematica requests has to end in .jsp, this is not possible. An alternative is to generate a URL that has the correct extension; this functionality is provided by MSPURLStore.
MSPReturn is useful when the commands are embedded inside an existing page and you just want to terminate processing the page and return the result. It is simpler to use the direct return technique, so this would be preferred if it is possible.

MSPURLStore

MSPURLStore uses the mechanism that webMathematica provides for storing images generated by commands such as MSPShow. It actually stores its argument on the server and returns a URL that references the argument.
In[1]:=
In[2]:=
In[3]:=
Out[3]=
The URL is relative to the request that contained the MSPURLStore. It contains a unique identifier and a description of the content type. Since the server steadily deletes stored information on the server, the information will not remain on the server indefinitely. This mechanism is particularly useful for preparing input for plug-ins and applets.
MSPURLStore can also take a third argument to set the filename, which is put into the URL that is returned. For example, the filename of notebook.nb is set in this example.
In[4]:=
Out[4]=
MSPURLStore is useful as a way of returning content if you need a URL such as in a src attribute of an img tag. This can be useful when working with dynamic client technologies such as AJAX or Flash.