webMathematica >

Data Loading and Computation

File I/O

<KernelInitializeCode>
MyApplication`DataDirectory="C:\\Work\\Data"
</KernelInitializeCode>
<msp:evaluate>
data = Import[ ToFileName[ MyApplication`DataDirectory, "file.dat"], "Table"];
</msp:evaluate>
<msp:evaluate>
data = Import[ ToFileName[MSPPageDirectory[], "file.dat"], "Table"];
</msp:evaluate>
This was used in the XML example Phone.jsp, which was discussed previously. It is particularly convenient to use MSPPageDirectory since it means that data and scripts live in the same directory. Thus the entire web application can be moved from one server to another with a minimum of setting up. One disadvantage is that for JSPs the data file can be loaded by a direct request to the server; thus it should only be used if there is no specialized information present in the data file. This might be the case if only certain information was suitable to be used in a response to each request.

HTTP Upload

Database Connectivity

DatabaseLink is based on Java Database Connectivity (JDBC) technology and so it fits very well with the Java technology on which webMathematica is based. It has many useful and important features (listed at http://reference.wolfram.com/mathematica/DatabaseLink/tutorial/Overview.html). One particularly useful feature for webMathematica is that DatabaseLink contains the HSQL Database Engine (HSQLDB), a lightweight database. This means that if you do not already have a database or want to experiment with using one, you do not have to set one up.
webMathematica contains two examples of working with a database. These are Database.jsp, which is accessible via http://localhost:8080/webMathematica/Examples/Database/Database.jsp and DatabaseTable.jsp, which is accessible via http://localhost:8080/webMathematica/Examples/Database/DatabaseTable.jsp. Note that for these links to work, you need to have installed webMathematica, and also the DatabaseLink example databases, as described in its documentation. The example databases are installed into $UserBaseDirectory, and so you need to make sure this is $UserBaseDirectory for the user who is running webMathematica.

Web Services

Data Examples

Loading Data: Load.jsp

If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Data/Load.jsp. (You may have some other URL for accessing your server.)

Uploading Data: Upload.jsp

If you installed webMathematica as described above, you should be able to connect to this example via http://localhost:8080/webMathematica/Examples/Data/Upload.html. (You may have some other URL for accessing your server.)

Session Storage of Data: Session.jsp

If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Data/Session.html. (You may have some other URL for accessing your server.)

Database Connections: Database.jsp

If you installed webMathematica as described above, you should be able to connect to this JSP via http://localhost:8080/webMathematica/Examples/Database/Database.jsp. (You may have some other URL for accessing your server.)