Subscribe to Windows IT Pro
October 01, 1996 12:00 AM

MFC ISAPI Extensions Hit Light Speed, Part 1

Windows IT Pro
InstantDoc ID #2771
Rating: (0)
Downloads
cmtDLL.zip

Part 1: Creating ActiveX forms on the Web

You've encountered them many times on the Web--those ubiquitous online forms. Home pages feature a variety of such forms for comments and suggestions, order processing, username validation, questionnaires, and searches, to mention a few. Online forms can fulfill each of these requests. Although such forms can also take time to process and add to the load on your Web server, with the right tools, you can create forms that don't drain your system.

With Windows NT Server and Microsoft's Visual C++ (VC++) 4.1, you can use Internet Server Application Program Interface (ISAPI) Extensions that will make your online forms move at light speed. Unlike forms you create with Perl or shell programming, forms based on ISAPI Extensions can improve NT Server's performance and are easy to create using the ISAPI Extension Wizard in the VC++ Microsoft Foundation Classes (MFCs). The Wizard walks you through creating an ISAPI Extension, a framework based on new MFC ISAPI Extension classes. The Wizard gives you easy programming, debugging, and maintenance all in one application.

To create ISAPI Extensions, you need Hypertext Transfer Protocol (HTTP) server software, VC++ 4.1, and a Common Gateway Interface (CGI)-compatible Web browser such as Internet Explorer (IE) or Netscape. The latest Microsoft Developer Network (MSDN) CD-ROM is also helpful for reference, but not required.

This how-to article explains the process of creating a custom ISAPI Extension with the MFC Wizard. You first need to understand CGI, how to create a form with Hypertext Markup Language (HTML) to call the ISAPI Extension, and how to create an ISAPI Extension for your form. Then, you can walk through using the Wizard to create the base implementation for an ISAPI Extension. A follow-on article will cover additions to the Wizard-generated ISAPI Extension that you need to produce and process an online form.

Beyond the Gateway
As Web traffic increases, so does the demand for fast and efficient processing. ISAPI Extensions can speed up your online forms to meet this demand.

All online forms require CGI. When you select Submit on a form, you trigger a CGI request to an HTTP server. The server uses a CGI program to process the CGI request and sends the output back to your Web browser. In turn, your browser interprets the HTML and displays the results as a Web page.

On an NT server, ISAPI Extensions allow speed and efficiency that blow away other CGI programs' performance. At the heart of the efficiency is how Microsoft's Internet Information Server (IIS) uses NT's threading technology and DLL capabilities. Threading increases the server's efficiency: Creating a new thread requires far less system resource than creating a new process, which is what traditional CGI does.

ISAPI Extensions are DLLs loaded into the site's IIS process on demand or at server startup. IIS uses threading to speed up CGI requests to an ISAPI Extension. The server creates a new thread for each CGI request, so the server can handle more than one CGI request at a time.

To handle specific CGI requests, you write a two-line CGI-request to method-name a parse map. The parse map specifies a class-method name you must add to the class the Wizard creates for you. Then, in the online form, you reference the ISAPI Extension filename and class-method name as the form's action. To illustrate this process, let's look at an example.

Creating a CGI Form
The first step in using an ISAPI Extension to generate and process an online form is to prepare the form's HTML. Let's consider an online form that solicits a comment or suggestion, such as the form in Screen 1.

On the form, you can fill in your name, email address, and comment or suggestion. After you click either Comment as in Screen 2, or Suggestion, you select Send to submit your comment or suggestion to the home page's owner or Web master.

When you click Send, you trigger the CGI program associated with the form. Then, as Screen 3 shows, the CGI responds by generating another Web page to confirm receipt of the comment or suggestion. A link on this page connects to another Web page which you see in Screen 4. It lists all comments and suggestions, including any you just submitted.

Listing 1 shows the HTML code for the sample comment and suggestion form. The title and header are the first two lines of code. The title, Comments and Suggestions, appears in the browser title bar, and the header, Comment and Suggestion Fill-out Form, appears at the beginning of the page in the browser. (The code for this example is on the Windows NT Magazine Web site at www.winntmag.com.)

The form body is standard HTML. The two input fields are WHOISIT, which appears next to Your Name:, and EMAIL, which appears next to Your email address:. The form's default value for Your Name: is Anonymous, and the default for Your email address: is myname@company.com.

The form has two mutually exclusive radio buttons, Comment or Suggestion. The CGI request sends a value of 1 for Comment and a value of 0 for Suggestion. The form initially appears with Comment selected. Then, a multiline, text type field, WISEWORDS, appears below the text, Words of Wisdom:. The field has five rows and 80 columns. Finally, you see two unnamed (because they are not on the command line) buttons: a submit button with a value of Send and a reset button with a value of Clear.

Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.