ACS Matlab Web Server Overview

relation between browser, web.mit.edu, Athena course locker, and
matweb.mit.edu

For a detailed diagram of how the Matlab Web Server components operate, see page 2-3 of the online manual. Note that the ACS server has been customized to work in our environment, and thus some descriptions in the manual do not match our configuration; the differences are documented below.

Using the ACS Matlab Web Server

Steps in building a matweb application

  1. Before you can get started, we must configure the server to recognize your application. This requires two pieces of information:

    1. name of application; as explained below, this should contain your subject number, with an underscore for punctuation, e.g. matweb29_123
    2. directory in course locker where top-level M-file will be stored, e.g. /mit/29.123/matlab

  2. To build your application, you will need to create three basic files:

    1. application M-file: underlying Matlab code for your application
    2. input HTML file: initial web page for your application, where the user will input data (via forms)
    3. output HTML template: template for web page which will display output to the user

    For each of these, MathWorks provides a template file which we have modified to indicate values specific to our environment:

    (To view the HTML files, follow the links and choose View->Source, or use File->Save As and select Source as the format.)

    In addition, we have a local files which indicate specific values to use if you will be generating graphics:

    and for making your top-level M-file act as a launcher for multiple applications:

    Other samples referred to in the manual can be found at http://matweb.mit.edu/demos/wsdemos/ but keep in mind that you will need to make local modifications as indicated in the above templates.

Notes on names, paths, and URLs

Summary of basic code elements

In the table below, strong text indicates a literal value to be used; code text indicates a variable to be replaced with your own value.

File Syntax Purpose
input HTML <form action="http://matweb.mit.edu/cgi-bin/matweb" method=post> CGI program on server which extracts input data
<input type="hidden" name="mlmfile" value="app-name"> mlmfile: name of main Matlab function (e.g., matweb29_123 from matweb29_123.m)
<input type="type" name="var" value="val" ... > form fields for user input
 
M-file function retstr = app-name(instruct) function def, e.g. function rs = matweb29_123(instruct)
(instruct is the Matlab structure which will contain the input data from your HTML form and other fields such as instruct.mlid used below)
mlid = getfield(instruct, 'mlid'); mlid: unique identifier (to form file names, e.g. for graphics)
cd /var/local/httpd/htdocs/matweb/tmp; working dir: temp dir on server for storage of graphics files, etc.
input_var = instruct.var assign user's input values to your variables
outstruct.var = ... structure for variables to be returned in output HTML, e.g.
outstruct.GraphFileName = sprintf('%sapp-name.jpeg', mlid) to store a unique file name for graphic (via mlid) in GraphFileName field of outstruct
wscleanup('ml*app-name.jpeg', 1); wscleanup: removes jpegs from app-name older than 1 hour. (We run a script on the server which periodically purges stale files, but recommend including this in your M-file to keep your application from eating up disk space unnecessarily.)
wsprintjpeg(fig, outstruct.GraphFileName); create jpeg file from figure, with above filename
templatefile = '/afs/path/to/output.html'; full path to output HTML file, e.g. /afs/athena/course/29/29.123/www/matweb-output.html
retstr = htmlrep(outstruct,templatefile) htmlrep: fills in values of Matlab variables in the output HTML file. For example, outstruct.GraphFileName from matweb29_123.m -> $GraphFileName$ in output.html.
 
output HTML $outputvar$ Matlab variable, to be replaced via htmlrep. For example, $GraphFileName$ in
<img src="/tmp/$GraphFileName$"> would be replaced with the filename of the generated graphic in the server's temp dir, such as <img src="/tmp/ml00465matweb29_123.jpeg">


Last modified: Wed Jan 17 10:17:21 2001
ajfox