WWWQUOTE: Demonstrates Development of an Internet Server Extension Using MFC

Click to open or copy the WWWQUOTE project files.

The WWWQUOTE sample illustrates the development of an Internet Server Extension using MFC. This extension makes use of ODBC to retrieve information from a database and provide it to the user via his/her HTTP connection to the server. The example shows proper use of the parse map macros, the CHttpServer class, and thread-safe programming techniques.

The WWWQUOTE sample can be built to use MFC in a shared DLL or to link statically to MFC.

This sample requires a Web server that supports the Internet Server Application Programming Interface (ISAPI), and should be run in an environment where a server-class database is available. For details, see "Installing the Sample" below.

Several issues, such as multithreading, require thoughtful handling when accessing a database from an ISAPI extension DLL. For a discussion of these issues, see Technical Note 67.

Installing the Sample

The WWWQUOTE sample is designed to demonstrate information retrieval in a high-throughput application. You need to use the sample with SQL Server and run the sample under Windows NT, Server Edition — the sample cannot be used with user-oriented database systems like Microsoft Access because they cannot provide the throughput necessary for a server application. You can configure the data source to work with another SQL database server, such as Oracle Server, but the instructions here discuss the use of SQL Server.

The sample files include a script that you can use in ISQL/W, the interactive SQL Server utility. ISQL/W allows you to create the tables and indexes, and insert data the sample uses. The script file is called Quotes.sql, and you can open it in ISQL/W and run it to create the tables. Before you run the script file, you should make sure you have attached ISQL/W to the correct database and you have set up the privileges. The script will create tables named CUSIP and PRICES. You can run the script in an existing database as long as your target database does not already contain objects with these names.

Once the database is installed, you'll need to create an ODBC system data source on the server as follows:

  1. Start the Windows NT Server Control Panel on the server and open the ODBC32 applet.

  2. In the ODBC32 applet, click System DSN.

  3. When the System Data Sources dialog box appears, click Add.

  4. In the Add Data Source dialog box, select the ODBC driver appropriate for your database server.

  5. In the Setup dialog box for your driver, specify a Data Source Name of "Stock Quotes". You can use whatever values you need for the other options. You will probably want to provide a default database name that matches the database you used when you ran the Quotes.sql script.

Once you have set up the database, copy the DLL file created when you built the server into a directory on your Web server. Make sure the file is stored in a directory that offers users of your server execution privileges.

Once the files have been installed, you can connect to the server from a client machine with your favorite Web browser. The quote program dynamically produces forms. You can respond to the forms and have the server generate stock quotes for you. There are only a few issues of stock with a few months of market activity in the sample database, but you can use the forms provided by the server in your own applications to request valid quote information.

To get started, use your browser to request that the server execute the Wwwquote.dll file. If your server is named www.mooseboy.com, you can use this URL to activate the program:

     http://www.mooseboy.com/scripts/wwwquote.dll?

You must provide the trailing question mark. Note that this example assumes your server has the WWWQUOTE sample DLL installed in a directory called scripts.