Windows IT Pro is the authoritative and independent resource for windows nt, windows 2000, windows 2003, windows xp. Features a collection of resources and magazines for windows IT professionals.
  
  
  Advanced Search 


October 1996

MFC ISAPI Extensions Hit Light Speed, Part 1


RSS
Subscribe to Windows IT Pro | See More Internet Server API (ISAPI) Articles Here | Reprints | Or get the Monthly Online Pass—only $5.95 a month!

Download the Code Here

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.

   Previous  [1]  2  Next 


Top Viewed ArticlesView all articles
No Jobs, No Excitement at Apple's Last Macworld Keynote

Apple CEO Steve Jobs made the right move in skipping out on his company's last appearance at Macworld: In a Tuesday keynote address at the conference, Apple had no interesting new products to sell, opting instead to spend mind-numbing amounts of time on ...

Where is Microsoft NetMeeting in Windows XP?

...

The Memory-Optimization Hoax

Don't believe the hype. At best, RAM optimizers have no effect. At worst, they seriously degrade performance. ...


Related Articles MFC ISAPI Extensions Hit Light Speed, Part 2

Windows OSs Whitepapers Why SaaS is the Right Solution for Log Management

Related Events Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Cloud Computing Forum: Integrating Software, Server and Storage as a Service into Your Enterprise IT Delivery Model

Virtualization Forum: Optimizing Storage, Networks, Desktops, and Security

Check out our list of Free Email Newsletters!

Windows OSs eBooks Understanding and Leveraging Code Signing Technologies

A Guide to Windows Certification and Public Keys

SQL Server Administration for Oracle DBAs

Related Windows OSs Resources Become a VIP member of the Windows IT Pro community!
Get it all with the VIP CD and VIP access. A $500+ value for only $279!

Subscribe to Windows IT Pro!
Solve your toughest technical problems with our experts and access 10,000 + articles online. 30% off

Monthly Online Pass - Only $5.95!
Get instant access to 10,000+ articles from Windows IT Pro Magazine!

TechNet Virtual Labs
Evaluate and test Microsoft's newest products.


Windows IT Pro Home Register FAQ for Windows WinInfo News
Europe Edition About Us Contact Us/Customer Service Media Kit Affiliates / Licensing  
SQL Server Magazine Office & SharePoint Pro Windows Dev Pro IT Job Hound ITTV
IT Library Technology Resource Directory Connected Home Windows Excavator Windows SuperSite 
 
 Windows IT Pro is a Division of Penton Media Inc.
 Copyright © 2009 Penton Media, Inc., All rights reserved. Terms and Use | Privacy Statement | Reprints and Licensing