8.4 Mapping URLs onto MSP Scripts
For users of webMathematica who write their content in MSP scripts, they are located inside the webMathematica web application, in the directory /webMathematica/WEB-INF/MSPScripts. This can be modified in the configuration file MSP.conf with the setting MSPDirectory. Of course, you may not want to keep all MSP scripts in the same directory, preferring to place them in a variety of different locations. This section discusses some of the ways that this can be done.
8.4.1 Script Directories
A URL, such as http://host/webMathematica/MSP/Script, will find the MSP Script.msp in the main directory. You can also place MSP scripts in subdirectories of the main directory. For example, a URL, such as http://host/webMathematica/MSP/Test/Script1, will locate Script1.msp in the subdirectory Test. When an MSP is loaded from a subdirectory, that subdirectory is added to the Mathematica $Path so that Mathematica packages and applications located in the subdirectory can be loaded with no need to specify the name of the subdirectory. Many of the MSP scripts located in the Examples directory that ship with webMathematica make use of this feature.
The following two tables give a summary on loading MSP scripts from the main directory and from subdirectories.
In the first table, the MSP Script.msp is located in the main directory, /usr/local/tomcat/webapps/webMathematica/WEB-INF/MSPScripts. It can be accessed by the URL http://host/webMathematica/MSP/Script. The configuration parameter MSPDirectory specifies the location of this directory, which is added to the Mathematica $Path.
In this second table, Script1.msp is located in a subdirectory of the main directory, /usr/local/tomcat/webapps/webMathematica/WEB-INF/MSPScripts/Test. The URL http://host/webMathematica/MSP/Test/Script1 will find this MSP script. In the Mathematica kernel, the directories /usr/local/tomcat/webapps/webMathematica/WEB-INF/MSPScripts and /usr/local/tomcat/webapps/webMathematica/WEB-INF/MSPScripts/Test are added to $Path.
Note that the same kernel pool serves the MSPs in the main and subdirectories. Consequently, they all have the same configuration details.