webMathematica >
webMathematica Tutorial

Dynamic HTML

When the web was first developed, it supported only the distribution of static pages. The technology was extended to allow interactive access for dynamic content generation.
Fundamentally, the web is driven by its main protocol, HTTP (Hyper Text Transfer Protocol), which imposes certain constraints. Under HTTP, a client sends a request to a server that replies with a response. A crucial feature of HTTP is that it is stateless; that is, after processing a request, no record of that request is kept. Of course, state information can be maintained via some other mechanism; for example, the servlet API has methods for keeping state that can be used with MSPSessionVariable.
This reference section reviews server and client technologies for dynamic web content. Because this field changes very rapidly, the survey is not intended to be exhaustive.

Server Technology

There are several server-side technologies for dynamic content. These include CGI scripting, Active Server Pages, server plug-ins, Perl scripting, and Java servlets and JavaServer Pages.

CGI Scripting

CGI scripts provided the original server technology for dynamic content. Under CGI, an executable, such as a shell script or compiled binary, is launched on every request.
This mechanism is limited in a number of key ways. It is relatively expensive since it requires launching a new CGI process for every request, which can cause scalability problems. One solution is to make the actual CGI script a lightweight process that communicates with its own server; many web solutions actually do this. Of course this requires nontrivial development and can result in something that is more complicated to use than other dynamic solutions.

Active Server Pages

Active Server Pages (ASPs) are a scripting language for dynamic web content, developed by Microsoft. They are quite common and powerful. At present, ASPs are not supported, but this will be continually reviewed.

Server Plug-ins

Most HTTP servers provide some type of extensibility that can be used to support special features for interactivity. The problem with this approach is that it is not very portable.

Perl Scripting

Perl is often used as a scripting language either with CGI or a server plug-in. Technologies exist to link Mathematica to Perl, but these are not as developed as is the technology for linking to Java.

Java Servlets and JavaServer Pages

Java Servlet technology provides a high-level API (programming interface) for working with HTTP requests. There are many ways that web servers can be enhanced to add a servlet engine. Solutions exist for all web servers and run on all major platforms.
The Servlet API is a high-level interface that provides functions both for maintaining information while the server is running and for working with HTTP requests and responses.
JavaServer Pages (JSPs) are a closely related technology that make it very convenient for servlets to return HTML; the server converts a JSP into a servlet, which is then executed.
webMathematica is implemented with a mixture of Java Servlet and JSP technology.

Client Technology

Ultimately, any content is downloaded to a client where it is rendered. In a sense, the purpose of server technology is to prepare input for a client. In the client there are also various dynamic content technologies. These include HTML, JavaScript, and applets.

HTML

The fundamental content delivered by web servers is HTML, a tree-structured language formed from tags. At present, HTML is being transitioned into a stricter language, XHMTL, an XML application.
HTML is fundamental to the topic of dynamic web content, so here is a short primer on dynamic web content with HTML.
First, start with a basic HTML document.
This could be downloaded from a web server and rendered in a web browser.
Active elements are added to HTML by form and input elements, which can be included inside an HTML document. Here is a form element.
The form has two attributes, an action attribute and a method attribute. When the form is activated, it will make a connection to this URL and use the post method.
Often the URL will be located on the same server from which the page was downloaded. In this case it is common to use a relative URL.
A form element may contain input elements, which add various buttons and input fields. Here is an example of a form with two input tags: the first allows text to be entered, and the second causes the form to be submitted.
When the form is activated by the submit input tag, the browser makes a request to the URL referred to by the action attribute. It sends the name and value pairs from all of the input tags in the form. This is the most basic way to activate HTML.
One thing to remember about form elements is that the name/value pairs can be specified in the URL. You may have seen them in something like http://myserver/document?ARG1=10&ARG2=20.

JavaScript

JavaScript is a compact object-based scripting language for developing client and server internet applications. JavaScript code can be embedded directly in an HTML page. It can, for example, embellish the operation of form and input elements. One problem with JavaScript is that it is not uniform across different browsers. JavaScript can manipulate the browser and the documents that the browser holds. It can also interact with applets and plug-ins.
Some of the examples included with webMathematica work with JavaScript.

Applets

Applets are programs written in Java that can run in a Java-enabled browser. They are less tightly integrated with HTML than JavaScript but are probably easier to develop and can call on much of Java technology. As with JavaScript, some (especially older) browsers give incomplete and poor support for applets. Applets can call on the large collection of functions that are available in the Java programming language and can actually draw into the browser.
Some of the examples are designed to work with applets.

Future Developments

The major browsers, Internet Explorer, Mozilla, and Netscape Navigator, continue to develop new interactive technologies at a rapid pace. It may be advantageous for webMathematica users to consider new technologies as they become available.