ASP Tutor for Beginners

Frequently Asked Questions On Active Server Pages




1. What is an Active Server Page (ASP)?

Active Server Pages is 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, etc.


2. With which Web servers can I use Active Server Pages?

Active Server Pages is currently available for the following Web
servers:

Microsoft Internet Information Server (IIS) 3.0
Microsoft Internet Information Server (IIS) 4.0
O'Reilly WebSite Pro


3. Is Active Server Pages an industry standard?

Active Server Pages is developed and maintained my Microsoft.
Although the company has published a lot of information about ASP
and associated technologies, ASP has not been approved by any
standards body.


4. Can I use Active Server Pages if my Web server is running on a
non-Windows machine?

Maybe. Through the use of ChiliSoft's (http://www.chilisoft.net)
ChiliASP! product, Active Server Pages is also available for a
number of other Web servers and operating systems, including a
number of Unix variants. Check with ChiliSoft for the latest details
regarding which platforms they support.


5. 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.


6. 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 perform to initialize variables at the start of
a user session or create application-wide database connections, etc.

7. 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: http://www.serverobjects.com/products.htm#Aspmail

8. 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 is actually an ActiveX Scripting Host
and can, therefore, 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
http://www.activestate.com/ActivePerl/docs/perlscript.html .

    9. 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, because ADO has built-in connection pooling.


10. 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 product
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 makes developing sites much
easier. Elemental's Drumbeat 2.0 (http://www.drumbeat.com/) is a
tool that focuses on making it easier to build visual
database-driven sites with a minimum of programming.


11. 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
(http://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.


12. 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://www.microsoft.com/workshop/server/toolbox/cookie.asp


13. 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. This is
because 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.


14. 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.


15. 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/).


16. How do Active Server Pages compare to Allaire's ColdFusion?

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


ASP Tutor for Beginners