Active Server Pages
 
  • What are Active Server Pages (ASP)?

  • Active Server Pages are a language-independent framework designed by Microsoft for efficient coding of server-side scripts that are designed to be executed by a Web server in response to a user's request for a URL. ASP scripts are similar to other server-side scripting you may be familiar with that are used on other platforms such as Perl, Python, and so on.
     
  • Are Active Server Pages an industry standard?

  • Active Server Pages are developed and maintained by Microsoft. Although the company has published a lot of information about ASP and associated technologies, ASP has not been approved by any standards body.
     
  • Why should I choose ASP as opposed to CGI or other scripting methods?

  • There are three main reasons to use ASP: 
    • Performance — With CGI, each script is run as an executable in its own process. As a result, each time a script is requested the server must: create new process, run the script, kill the (just created) process. This is inefficient and can severely impact the performance of the Web server. The Active Server Pages host is not re-launched with every script access and is therefore much more efficient.
    • Session management — Because HTTP is stateless, keeping track of data between page accesses by a user is a tough problem. ASP provides built-in session management functionality that allows developers to persist data and also COM component instances (like database connections) for the duration of a session.
    • Easy integration of COM components — ASP is designed to rely heavily on COM components for its extensibility. As a result, it is very easy to instantiate and use any COM component from within an ASP script.
  • What is the global.asa file? What is it used for?

  • The global.asa file allows you to add code that will automatically execute at the start and end of a user session and also at the start and end of the "application." As a developer, you can use the code in the global.asa file to initialize variables at the start of a user session or create application-wide database connections, and so forth.
     
  • Can I send e-mail from an ASP script?

  • Yes. If you're using ASP on a server with the NT 4.0 Option Pack installed and Microsoft SMTP Service (from the Option Pack) running then you can use the CDONTS component to easily send Internet e-mail from you ASP script. This component is available free of charge.

    There are also a number of custom components available from third-party sources that provide more configuration options and do not require Microsoft's SMTP service or the Option Pack. The most popular of these components is ASPMail. For more information on this product, check out: www.serverobjects.com/products.htm#Aspmail

  • Do I have to write ASP scripts in VBScript? Isn't ASP supposed to be language-independent?

  • No, you don't have to write ASP scripts in VBScript if you don't want to. Active Server Pages are actually an ActiveX Scripting Host and ,therefore, can use any compatible ActiveX Scripting Engine. Scripting engines for VBScript and JScript (Microsoft's JavaScript variant) come pre-configured with ASP when installed as part of the Internet Information Server. You also use any of a number of scripting engines available from third parties. For example, you can get more information about PerlScript, a Perl-based scripting engine, from the ActiveState site at www.activestate.com/ActivePerl/docs/perlscript.html .
  • I want to be able to access a database from a Web page. Can I do this with ASP?

  • Yes, ASP makes accessing databases very easy. Although developers can use virtually any database library from within their scripts, ASP is really geared towards database access via Microsoft's ActiveX Data Objects (ADO). ADO is fairly lightweight and allows easy access to any ODBC or OLEDB compliant data source including Microsoft Access (Jet), Microsoft SQL Server, and Oracle databases. In addition, ADO has built-in connection pooling.
  • Do I have to use a specific editor or development environment to create ASP scripts?

  • No, Active Server Pages scripts are standard text files that can be edited with any text editor. That said, there a number of products that make working with ASP scripts easier. Microsoft's Visual InterDev 6.0 (http://msdn.microsoft.com/vinterdev/) development environment (sold separately and also as part of the Visual Studio development suite) features a color-coding editor, database wizards, and project management features that make developing sites much easier. Macromedia's Drumbeat 2000 (www.drumbeat.com) is a tool that focuses on making it easier to build visual database-driven sites with a minimum of programming.
  • Do I have to use a specific language or environment to create server-side COM components to use from within ASP?

  • No, any development environment that can produce OLE Automation Servers can make components that are compatible with Active Server Pages. Popular authoring tools for components include Microsoft C++ (http://msdn.microsoft.com/visualc), Microsoft Visual Basic (http://msdn.microsoft.com/vbasic/), and Inprise Delphi (www.inprise.com/delphi/). There are special requirements when writing components for use with ASP, but component developers should be mindful of threading and other similar issues that come up when programming for multi-user environments like the Web.
  • Whenever my users access an ASP script, the Web server tries to set a cookie in their browser. Are cookies required for ASP?

  • Active Server Pages doesn't require cookies unless your code uses the framework's built-in session management functionality. ASP uses cookies to maintain state between page requests and determine which set of session information is for which user. If you'd really like to avoid cookies you can either turn off the session functionality or install Microsoft's beta "Cookie Munger" filter (IIS only). For more information about the "Cookie Munger" filter take a look at: http://msdn.microsoft.com/workshop/server/toolbox/cookie.asp
  • Do I need to know HTML to program using Active Server Pages?

  • Although strictly speaking, knowing HTML is not required, as a practical matter you will find knowing it to be a necessity. The vast majority of server-side scripting, ASP included, involves doing some kind of server-based processing and then returning a result to the user in the form of an HTML page. As part of your development process, you'll invariably run into situations where your ASP script is running without errors but the HTML it generates does not display correctly in the user's browser. When it comes to debugging these types of problems you'll find that having a good handle on HTML to be invaluable.
  • If I write scripts in ASP will my users be able to see my code?

  • If your Web server is properly configured, then users will only see the HTML output your ASP script generates, not the ASP code itself. 
  • How do I debug my Active Server Pages scripts?

  • The easiest way to debug ASP scripts is to use Microsoft's Script Debugger. You can install this tool as part of the NT Option Pack or download it for free from Microsoft's Web site (http://msdn.microsoft.com/scripting/debugger/). 
  • How do Active Server Pages compare to Allaire's (www.allaire.com) ColdFusion? 

  • At a high level the two technologies are very similar and, as a result, you can view them as competitors. ColdFusion is more Web-server independent, while Active Server Pages work best with Microsoft's IIS. 


    Feldman, Boris, asp-zone.com