Programmer's Heaven - For C C++ Pascal Delphi Visual Basic Assembler C# .Net java JSP ASP ASP.NET Javascript developers!

Members
Username:

Password:

Auto-login

Register
Why register?
Forgot Password?
Blogs new Blog section
Jobs
Webtools
Message Boards
FAQ
CodePedia
Free Magazines
User search
What's New
Top lists
RSS Feeds RSS Feed

Submit content
Contact Us
Link To Us
Help



Advanced Search
Newsletter
E-mail:


More information
Current area: HOME -> Discover ISAPI. Feed provider for graphical applets

Sample Image - Isapi_Applets.gif

Introduction

    Some time ago I implemented a data feed system from SQL database to some graphical applets.
    At the beginning we decided a normal ASP script who read data and give it to that applets will be usefully. Unfortunately wasn't !
    The web server was crashed every time the number of simultaneous users on the site was bigger like 80-100 and when an user tried to get bigger data in an applet.
    For that reasons we decided to move the feed on the ISAPI dll.

Advantages

  • 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 will dont produce any time aout caused by applets calls.
  • keeping of connection to DB in the ISAPI cache, in that way all request against DB will don't loose time with open connection,  will use that public open connection variable (CAdoDatabase   m_AdoDB).
  • ISAPI extension dll are the best choice if you want to obtain the maximum number of simultaneous connection to IIS web
    server or to provide huge quantities of HTML data.

Functionality

    The ASP script load the applet class and give it some parameters, like colors, time interval of http's requests,
web application URL, etc. 
<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/IsapiDemoFeed.dll?GetOnlineScrollerData?" param name="updateInterval" value="20000"</applet>

    The java applet will made from the clients side to web server HTTP requests at the received web URL parameter. That request are maded at equal interval of times give in milliseconds by "updateInterval" parameter. If will open the java console on the client will see some messages like:

    Loading data from 
http://localhost/projects/Articles/AspDemoFeed/cgi-bin/IsapiDemoFeed.dll?GetOnlineScrollerData?0&4

    The ISAPI module respond to that HTTP hit with a know by applet format, html stream:

0|2232160|453.4|2|14:19:06
1|576920|139.1|1|14:19:06
2|4006410|796.8|4|14:19:06
3|2511860|-31.5|2|14:19:06
4|2478810|529.2|0|14:19:06 
    At each HTTP hit, the ISAPI module make request again SQL database, using the CAdoDatabase and CAdoRecordset classes from CodeProject site :). The minor modification was the keep only database connection  as public variable.
On each method the record sets needed are open and close. An optimization is the using of GetString method of AdoRecordset class, who return directly a formatted data text. Because the ISAPI dll is harder to debug, more attention must be to the errors capture, resolved with try/catch macros.
try
{	CAdoRecordset* AdoRS = new CAdoRecordset; 		//create a recordset variable 
	if ( DBConnectionOpen( m_bstrConnectionString ) ) 	//look at db connection to be online
	{ 						//open the recordset
		if ( AdoRS->Open(m_AdoDB.GetActiveConnection(), bstrSTMT, adOpenForwardOnly, 
				adLockReadOnly, adUseClient ) ) //here the disc params
		{ 	if(!AdoRS->IsEof()) 		//look if we have records
				varOutput = AdoRS->GetString("|", "\n", 0 );			
			else
				varOutput = "0 0 0 0 0 ";
AdoRS->Close(); //close the recordset if (AdoRS) delete AdoRS;
}else //set the custom error { wsprintf(wcOut,"Encountered Error:<br>%s<br>%s<br>%s<br>%s<br>","MyFunction" (LPCTSTR)m_AdoDB.GetLastError(), "RS isnt open", bstrSTMT );
*pCtxt << wcOut ; return;
}
}else //set the custom error { wsprintf(wcOut, "Encountered Error:<br>%s<br>%s<br>%s<br>%s<br>","GetMarketMapData", (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 the output
    !!!    To test the feed, must make updates on the values of tblOnline* tables. That updating will be online reflected instantaneous to the Online tables and scrolling applets. To see how is working Intraday charts applets make inserts in tblIntraday* tables. Thats applets look permanently at thats tables and updates our values in cells and points on the charts.

Install

  • The ASP connection string are located in the Includes\_incConnectionOn.asp file.
    cnx.Provider = "sqloledb"
    cnx.Open "Data Source=andi;Initial Catalog=ArticlesIsapiFeed;", "sa", ""
  • The ISAPI connection string are located in IsapiDemoFeed.cpp file, on the constructor:
    m_bstrConnectionString="Provider=SQLOLEDB;Data Source=andi;Initial Catalog=ArticlesIsapiFeed;
    UserID=sa;Password=;";
  • Copy the folder "AspDemoFeed" under your web site and make it ASP application, to work the session and
    application ASP objects.
  • Give "Scripts and Executables" Execute Permision to "cgi-bin" directory of "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 restore database option on SQL Server Enterprise Manager and choose
     the "DB/ArticlesIsapiFeed.bak" file backup. The name of database is ArticlesIsapiFeed.

About Adrian Bacaianu

I make programming for over 4 years and extensive experience in C++, ASP, Pascal, MFC, COM+, ATL, TCP/IP, HTTP protocols, XML, XSL, SOAP and SQL. For the last 2 years i working extensively at the background of financial sites (databases, n tier architecture).

I’m available for contracts and/or outsourcing. Contact adrian_bacaianu@yahoo.com.


  User Comments

This article has not been rated or commented on yet. Why not take a moment to
post your comments and rate this article?

      Rate and comment this article


Think you've can write or have written a good article? Want to get it hosted for free on a highly respected programming site? Get the attention you deserve! Click here to find our more

 

Sponsored Links 
Build IT Knowledge with Current & Trusted Content
Helps Employees Develop & Hone New Technical Programming Skills. Sign Up & Get Full Access.
Check Out IT Certification Preparation Materials
Sign Up With SkillSoft & Get Access to Training Materials for Over 50 Professional Certifications.
Villanova University Six Sigma & IT Certificate Programs
100% Online programs in Six Sigma, IS Security, CISSP Prep, Business Analysis, Proj. Mgmt. and more!
Virtual File System SDK
Create your own file systems in Windows and .NET applications
PureCM Software Configuration Management
Version control and integrated issue tracking - powerful and easy to use. Get your FREE trial now!
Buy a link now

Newsletter Submit Content About Advertising Awards Contact Us Link to us    
© 1996-2008 Community Networks Ltd All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by .NET konsult - Synchron Data.