Chapter 3 Introduction to PowerDynamo


Databases and the Web

This section describes how databases can be connected to the Internet using a suitable application server, or gateway, and also describes the kind of information commonly stored in databases.

Gateways between Web servers and databases


For a Web server to retrieve information from a database, an intermediary application server or gateway is required between the Web server and the database management system (DBMS). Such an intermediary must have an interface to both the Web server and the DBMS. The most common Web server interface is named CGI. Each DBMS has a native interface; open interfaces such as ODBC and Open Client are also available.

Web server interfaces

CGI (Common Gateway Interface) is a standard Web server interface. When a Web server receives a URL corresponding to a CGI resource, it starts a CGI program (such as a perl script, or the PowerDynamo application server) which connects to the DBMS, queries the database, and returns the information to the Web server to be handed on to the Web client.

CGI is a standard for interfacing any external application with a Web server, not just a DBMS. CGI applications may also simply process files. The output of the CGI program or script is returned to the Web server. This output may be an HTML document, an image, a reference to another document, or any other form of information understood by the Web server.

CGI is an industry-standard Web server interface. Some Web server vendors also provide proprietary interfaces to their servers: NSAPI (Netscape Application Programming Interface) and Microsoft ISAPI (Internet Server Application Programming Interface) are two examples supported by PowerDynamo.

Static and dynamic Web pages

An HTML document stored in a file is an example of a static Web page: its content does not change unless the file itself is edited.

With application servers, you can create dynamic Web pages. A dynamic Web page is generated each time it is accessed. Because dynamic pages are generated on the fly, they can have features not found in static Web pages:

Templates and data

A dynamic Web page can contain:


The static components of the page are stored in an HTML document called a template. The template consists of the static HTML text (which is passed on to the Web client without change) together with the query or other instruction defining the dynamic component of the page, and the layout instructions governing the display of the data.

The query tags are interpreted by the application server: they are never seen by the client themselves, because the query is replaced by its result set when the document is generated. The application connecting the database to the Web server replaces the query with its data, formatted according to the instructions, and sends the resulting page to the Web server for relay to the Web client.

Storing and accessing Web information in a database

Information that can be stored in a database for Internet access falls into two broad categories:

Accessing existing data

Existing data in a database can be accessed from the Internet using an application server. In this case, the application server merges an HTML document (which may exist inside or outside the database) with information stored in the database, and sends the resulting HTML document to the Web server.

For example, a dynamically generated Web page may display pictures and descriptions of a product line, stored in HTML files, but fill in the prices, contact information, and other information from the database.

HTML documents

HTML documents themselves can be stored in a database. At its simplest, the task of the application server is then to execute a query that retrieves the HTML document from the database and passes it to the Web server.

Images and other external data

Images and other non-HTML information can also be stored in a database. When the image is requested, the application server retrieves it from the database and passes it to the Web server.

All of the above

An application server can retrieve an HTML document from the database, fill in part of the document from data stored elsewhere in the database, and also provide images and other external resources associated with the document from the database.

PowerDynamo

With PowerDynamo you can create, store, manage, and access both HTML documents and data, using a database as the repository for one or both.

Also, by using SQL Remote replication technology, PowerDynamo allows an entire Web site or portions of it to be replicated onto a laptop computer and used offline, bringing dynamic content to users even when disconnected from the Web.

Further, because the underlying data and the HTML templates can be replicated in both directions, Web-hosted client/server applications can be run while offline, updating a local database. The changes can then be replicated back to the central server.

A glance at PowerDynamo

PowerDynamo includes Web-site management features and mobile intranet capabilities.

Building applications and managing Web sites

With PowerDynamo, you can embed instructions into any Web page, and process these instructions when providing HTML to a Web client for viewing or interaction. PowerDynamo supports the following kinds of embedded instructions:

Sybase Central manages all aspects of dynamic Web content:

Taking your intranet on the road

With PowerDynamo and SQL Remote replication technology, you can provide dynamic Web content to disconnected mobile users. An intranet site and the accompanying database can be replicated in one step, and a Personal Web Server allows offline access to both static and dynamic HTML content.

The Personal Web Server has a built-in interpreter for carrying out instructions embedded in Web pages.


SQL Remote allows the replication of both Web pages and data, so that the mobile user has access to dynamic content even when disconnected. SQL Remote is a fully transaction-based replication technology that allows updates to be made at either the consolidated database or at the database on the laptop. With SQL Remote you can even use a Web client to make updates to the local database, which are replicated to the office the next time you connect. This gives you Web-hosted client/server on the road. For more information about the mobile intranet, see the chapter on setting up a mobile intranet in the PowerDynamo User's Guide.

The interpreter

At the core of PowerDynamo is an interpreter that processes specially tagged instructions embedded in the HTML pages or other documents, and serves the resulting output together with static HTML to an application such as a Web server.

The Dynamo interpreter is built into several components:

Web-site management

For managing HTML templates and connections, PowerDynamo includes a Web-site management utility, which plugs in to Sybase Central and includes tools for these management tasks:

Sybase Central requires either Windows 95/98 or Windows NT.

HTML templates and scripts

HTML pages are static Web documents that consist of text and images with HTML tags indicating their meaning and structure. Dynamo can work with static Web documents and two types of dynamic Web pages: HTML templates and scripts.

A template can contain instructions as well as static HTML. These instructions are interpreted when a document is requested by a Web client. The client sees only the results of those instructions.

The PowerDynamo interpreter executes SQL statements against a database, interprets scripts internally, and can use text replacement and host variables to provide client/server interactions.

Scripts are programs that generate HTML. Scripts can be embedded in templates or stored as standalone programs. When the interpreter processes a script, it passes any output to the Web client.

Embedding dynamic content in a template

Sybase Central provides a wizard-based interface for initial design of an HTML template. The wizard allows you to build and test a SQL query from a query editor, and to choose from a variety of layout formats. Once the template is created, you can use any Web page authoring tool to enhance the page layout.

SQL queries in a template

With PowerDynamo, you can embed SQL queries in an HTML or XML template. This allows you to provide flexible and controlled Intranet or Internet access to data in your organization databases.

For example, you could develop a template that contains a query for company products, product descriptions, pricing and availability. When a Web client requests the page, the user sees up-to-the-minute information, generated in response to the request for the page.

With support for text substitution and host variables, you are not limited to static SQL statements. You can build SQL statements in response to input from a Web client.

For example, you could provide a Web template with a list box containing categories of products. When the user selects one of these categories and clicks a button, the Web client sends a request containing the selected category in the URL. In response, the application server constructs a query limited to the selected category.

Scripts in a template

For more flexibility over template content, PowerDynamo provides DynaScript, which is a JavaScript compatible language. JavaScript is a compact, object-based scripting language for developing client and server Internet applications.

For more information about JavaScript, see the Netscape JavaScript Authoring Guide

Script instructions can be embedded in an HTML template. When marked with the correct tags, these scripts are recognized and interpreted by the PowerDynamo interpreter, and the script output is sent on as HTML to the Web server for relaying to the client.

Note   Script language imposes no restrictions on Web client JavaScript was developed by Netscape primarily for interpretation at the Web client, not at the Web server. Consequently JavaScript has been tied to the Netscape Navigator browser. In PowerDynamo, appropriately tagged DynaScript scripts are interpreted at the server, and only the output HTML is sent to the Web client. The PowerDynamo inclusion of a JavaScript-based language as its scripting language places no restrictions on the Web clients that can use the system.

Text substitution and host variables

To enable real interaction between a Web client and the Web server, an action at the client (clicking on a button after filling out a form, for example) must send information to the Web server, and this information must be used by the application server in formulating its response. PowerDynamo supports this function using text substitution macros and host variables. Both are sent to the Web server as part of the address when a link or button in the client is clicked.

You can include a macro in an HTML template at any place in the content. This macro is expanded by the interpreter when the template is processed, being replaced by its value.

The value of a macro is defined in the URL when the page is accessed. The following example shows how text substitution works.

  1. A user at a Web client fills out an HTML form to subscribe to a service. The form includes fields for their first and last name.
  2. When the form is sent to the Web server, the user's entry is sent along with the request in the URL. The standard form for such an inclusion is as in the following example:
    http://www.organization.com/template-name?firstname=Janelastname=Smith

  3. In the HTML template, the symbol $firstname is replaced by Jane and the symbol $lastname by Smith wherever they appear. For example, a returned acknowledgment may include:

Dear Jane Smith,Thank you for your registration. Your registration number is 123-456.

For more information about text substitution, see the section on passing variables from one document to another in the PowerDynamo User's Guide.

For more information about text substitution with DynaScript, see the value property in the PowerDynamo Reference.

While text substitution macros are ideal for general-purpose substitution, there are some circumstances where a similar but alternative method has performance advantages. Host variables can be specified in a SQL statement and the statement can be executed repeatedly without being reparsed, providing significant performance improvements.

The data source

Queries embedded in a template are executed against a database. This can be any single data source, and the SQL statement must conform to the SQL supported by the database. The queries are executed against one and only one data source. This may be the same or a different database than the one in which the templates themselves are stored.

The template repository

The PowerDynamo application server allows templates to be held in a data source that can process Transact-SQL queries, or in the file system. The two supported databases for template storage are Sybase Adaptive Server Anywhere and Sybase Adaptive Server Enterprise. PowerDynamo can use an ODBC connection for either of these DBMSs, or an Open Client connection for Adaptive Server. The database need not be the same one as the one holding the data referenced in SQL statements embedded in the templates.

Although it is held in a relational database, a database-based template repository is organized according to a folder-based motif, which mimics a file system organization. This allows easy import and export of Web sites between the database and a file system, so you can continue to use tools geared to managing and working with file-based Web sites and information, and yet gain the benefits of a database-hosted Web site.

How the pieces fit together

The application server takes an HTML template from the template repository, processes script instructions embedded in this template, fetches data as required from the data store, and passes a finished HTML document to the Web server for relaying to the Web client.


 


Copyright © 2000 Sybase, Inc. All rights reserved.