MATLAB Web Server Previous page   Next Page

Using matlabserver

When we viewed the source of the webmagic1.html file, we observed the line of HTML code

and we noted that this line establishes communication with MATLAB. matweb is a program that resides on the HTTP server and communicates with matlabserver. matweb requires information found in matweb.conf to locate matlabserver (which could be running on a different machine).

matweb Program

matweb is a client of matlabserver that uses Common Gateway Interface (CGI) to get data from HTML forms. It transfers the information to matlabserver, which then runs applications written in M-files to produce responses.

When the MATLAB Web Server is installed, matweb is placed in
<matlab>/webserver/bin/arch for all architectures. This placement allows you to run matweb on a machine having the HTTPD but not having MATLAB installed and being of a different architecture from the server.

For HTTP server access you must also place a copy of matweb in the directory denoted by the /cgi-bin alias. The installation process places a copy in <matlab>/toolbox/webserver/wsdemos to run the sample applications.

matweb.conf

To connect with matlabserver, matweb requires information stored in the configuration file matweb.conf. Create this file inside the directory denoted by /cgi-bin, along with the matweb program. Use the copy in
<matlab>/toolbox/webserver/wsdemos as a guide.

An instance of matweb.conf looks like

Multiple application configurations must appear in the same file. Each variable appears on a separate line followed by an equal sign =, which is then followed by a value, e.g., mlserver=parrot. Applications are delineated by the main application entry point name (M-file) in square brackets []. For example, [webpeaks] is on one line followed by all its variables and corresponding values. Note that webmagic does not require an mldir entry because it does not generate any graphics or save any files. Use the % or # character at the beginning of any line to comment it out.

All the fields that can be contained in matweb.conf are described in Table 3-2.

Table 3-2: matweb.conf Fields 
Variable
Description
Sample Value
[application]
(required)

Name of the MATLAB application to run
webmagic
mldir
(optional)

    Working directory for reading or writing files. If specified, this directory is automatically added to the MATLAB path.
<matlab>/toolbox/webserver/wsdemos
mllog
(optional)

Produces an application-specific log file that records all exchanges between the application and MATLAB. Turn off logging when the program is running because logging has a negative impact on performance.
<matlab>/toolbox/webserver/wsdemos/webmagic.log

mlserver
(required)

    Name of host running matlabserver
parrot
mlport
(optional)
Port that matlabserver listens on. This value must correspond to the port number set in the matlabserver.conf file or on the command line (the p argument).
8888 (default)
mltimeout
(optional)

Seconds to wait for matlabserver before timing out
180 (default)
my_var
User-created configuration variable
value

After you create a new MATLAB Web Server application and enter its configuration data into matweb.conf, you need to restart matlabserver before you can use the application.

matweb M-File

Looking again at the source from the webmagic1.html file (see webmagic Input), observe that the line

sets argument mlmfile to the value webmagic. The mlmfile argument contains the name of the MATLAB M-file to run.

matlabserver uses the value of mlmfile obtained from the matweb M-file, matweb.m, (webmagic in this example) to run the MATLAB application. webmagic takes the input data from webmagic1.html, computes the magic square of the requested dimensions, and outputs the results using webmagic2.html as a template.


Previous page  matlabserver.conf Returning Results via the Web Next page