Discover ISAPI — Feed Provider for Graphical Applets

Click here for a larger image.

Environment: ISAPI


Some time ago, I implemented a data feed system from a SQL database to some graphical applets. At the beginning, we decided that a normal ASP script that read data and gave it to that applets would be useful. Unfortunately, it wasn’t! The Web server crashed every time the number of simultaneous users on the site was bigger that 80-100 and when a user tried to get bigger data in an applet. For that reason, we decided to move the feed to the ISAPI DLL.


  • The ASP server is freed by the calls from clients’ applets. In that way, the ASP will respond only to the normal site calls; the ASP won’t produce any time outs caused by applets calls.
  • Keeping the connection to the DB in the ISAPI cache. In that way, all requests against the DB won’t lose time with the open connection; they will use that public open connection variable (CAdoDatabase m_AdoDB).
  • ISAPI extension DLLs are the best choice if you want to obtain the maximum number of simultaneous connections to the IIS Web server or to provide huge quantities of HTML data.


The ASP script loads the applet class and gives it some parameters, such as colors, time interval of HTTP’s requests, Web application URL, and so forth.

<applet codebase="../AspDemoFeed/Tools/OnlineScroll/CLASSES/
        JavaScroller/" archive="../AspDemoFeed/Tools/OnlineScroll/
        Scroller.jar" code="ScrollerStartUp.class" width="600"
height="20" VIEWASTEXT id="Scroller">
  param name="speed" value="3"
  param name="bgcolor" value="696969"
  param name="Font" value="Arial|1|16"
  param name="changeFontSize" value="11"
  param name= "feedURL"value="<%=Application("WebURL")%>cgi-bin/
  param name="updateInterval" value="20000"</applet>

The Java applet will make HTTP requests from the client side to the Web server at the received Web URL parameter. That request is made an equal interval of times given in milliseconds by the “updateInterval” parameter. If you open the Java console on the client, you will see some messages such as:

Loading data from

The ISAPI module responds to that HTTP hit with a known applet format, HTML stream:


At each HTTP hit, the ISAPI module makes another request to the SQL database, using the CAdoDatabase and CAdoRecordset classes. The minor modification was to keep only the database connection as a public variable. On each method, the needed record sets are opened and closed. An optimization is the using of the GetString method of the AdoRecordset class, which returns directly formatted data text. Because the ISAPI DLL is harder to debug, more attention must be given to the errors capture, resolved with try/catch macros.

{CAdoRecordset* AdoRS = new CAdoRecordset;
               //create a recordset variable
  if ( DBConnectionOpen( m_bstrConnectionString ) )
               //look at the DB connection to see whether
               //it's online
  {            //open the recordset
    if ( AdoRS->Open(m_AdoDB.GetActiveConnection(), bstrSTMT,
         adOpenForwardOnly, adLockReadOnly, adUseClient ) )
               //here are the disc params
    { if(!AdoRS->IsEof())           //see whether we have records
        varOutput = AdoRS->GetString("|", "\n", 0 );
        varOutput = "0 0 0 0 0 ";
      AdoRS->Close();              //close the recordset
      if (AdoRS) delete AdoRS;
    }else                          //set the custom error
    { wsprintf(wcOut,"Encountered Error:
      (LPCTSTR)m_AdoDB.GetLastError(), "RS isnt open", bstrSTMT );
      *pCtxt << wcOut ;            return;
  }else                            //set the custom error
  { wsprintf(wcOut, "Encountered Error:
    (LPCTSTR)m_AdoDB.GetLastError(), "DB isn't open", bstrSTMT );
    *pCtxt << wcOut ;              return;
catch(_com_error err)
{   wsprintf(wcOut, "Encountered Error :
    <br>%s<br>%d<br>%s<br>", (LPSTR)err.Description(),
  err.Error(), (LPSTR)err.ErrorMessage() );
  *pCtxt << wcOut ;               return;
*pCtxt << varOutput;              //here's the output

Note: To test the feed, you must use make updates on the values of the tblOnline* tables. That updating will be online, reflected instantaneously to the online tables and scrolling applets. To see how Intraday charts applets are working, make inserts in tblIntraday* tables. Those applets look permanently at those tables and updates our values in cells and points to the charts.


  • The ASP connection string is located in the Includes\_incConnectionOn.asp file.
  •   cnx.Provider = "sqloledb"
      cnx.Open "Data Source=andi;Initial
          ", "sa", ""
  • The ISAPI connection string is located in the IsapiDemoFeed.cpp file, on the constructor:
  •   m_bstrConnectionString="Provider=SQLOLEDB;Data
  • Copy the folder “AspDemoFeed” under your Web site and make it an ASP application to work the session and application ASP objects.
  • Give the “Scripts and Executables” Execute Permission to the “cgi-bin” directory of the “AspDemoFeed” Web application. In that way, the ISS Web server will be able to execute the IsapiDemoFeed.dll.
  • To install the database on your SQL server, select the Restore Database option on SQL Server Enterprise Manager and choose the “DB/ArticlesIsapiFeed.bak” file backup. The name of the database is ArticlesIsapiFeed.


Download ISAPI source files – 107 Kb
Download Web project files – 328 Kb
Download DB backup files – 319 Kb

More by Author

Must Read