Developing ASP Components

Overview

Microsoft's Active Server Pages (ASP) technology has become wildly popular with web developers. However, the techniques for developing custom ASP components, not to mention the inevitable snags and pitfalls, are not well documented. What's more, the successful ASP component developer must be a jack-of-all-trades, with some knowledge of COM and COM+, threading models, and the ASP object model, as well as a mastery of one or more language tools and development environments.

That's...

See more details below
Paperback (Second Edition)
$38.24
BN.com price
(Save 23%)$49.95 List Price
Other sellers (Paperback)
  • All (43) from $1.99   
  • New (11) from $17.03   
  • Used (32) from $1.99   
Sending request ...

Overview

Microsoft's Active Server Pages (ASP) technology has become wildly popular with web developers. However, the techniques for developing custom ASP components, not to mention the inevitable snags and pitfalls, are not well documented. What's more, the successful ASP component developer must be a jack-of-all-trades, with some knowledge of COM and COM+, threading models, and the ASP object model, as well as a mastery of one or more language tools and development environments.

That's where Developing ASP Components, 2nd Edition, comes in. Its first section explores the topics everyone needs to know to develop effective ASP components:

  • Configuring the ASP development environment.
  • ASP components and the Component Object Model (COM).
  • ASP components and threading models.
  • ASP components and Component Services, which provide a variety of services to ASP components.
  • The objects, properties, methods, and events available in the ASP object model.
  • Integrating ASP components and scripted Active Server Pages.

ASP components are language independent, and developers increasingly tend to use more than a single language tool. Thus the remainder of the book focuses on ASP component development using one of two major development tools—Microsoft Visual Basic and Microsoft Visual C++ (with the ActiveX Template Library)—along with a number of other languages, such as Perl and Delphi. Each section focuses on the issues that concern the ASP component developer using that particular development environment. These issues include:

  • Accessing ASP's intrinsic objects.
  • Accessing data using ADO.
  • Creating n-tier web applicationswith VB.
  • Handling persistence using MFC along with Visual C++/ATL.

It's this strong focus on two major development environments, along with a thorough grounding in essential ASP topics, that makes Developing ASP Components, 2nd Edition, the definitive resource for the ASP application and component developer.

Read More Show Less

Editorial Reviews

From Barnes & Noble
To be an effective ASP component developer, you need to know more than ASP: You need familiarity with COM, COM+, threading, and a whole lot more. This book covers all of it, showing you how to build robust ASP components with either VB or Visual C++, as well as helping you avoid the poorly documented pitfalls that have snagged all too many ASP developers. Start with the basics: ASP component services, the ASP object model, and how to integrate ASP components with scripted ASP pages. Then, focus on sophisticated techniques specific to your development environment, including persistence solutions that leverage MFC and ATL; server-side VB components for XML programming; and more.
From The Critics
Explains how to create custom component object model (COM) components that interface with active server pages (ASP) and Microsoft's internet information server (IIS). Separate parts cover component development using Visual Basic and Visual C++. The second edition has been updated to reflect IIS 5.0, ASP 3.0, and Windows 2000. Annotation c. Book News, Inc., Portland, OR (booknews.com)
Read More Show Less

Product Details

  • ISBN-13: 9781565927506
  • Publisher: O'Reilly Media, Incorporated
  • Publication date: 3/22/2001
  • Series: Oreilly Temp Net Series
  • Edition description: Second Edition
  • Edition number: 2
  • Pages: 832
  • Product dimensions: 7.01 (w) x 9.20 (h) x 1.46 (d)

Meet the Author

Shelley Powers is an independent contractor, currently living in St. Louis, who specializes in technology architecture and software development. She's authored several computer books, including Developing ASP Components, Unix Power Tools 3rd edition, Essential Blogging, and Practical RDF. In addition, Shelley has also written several articles related primarily to web technology, many for O'Reilly. Shelley's web site network is at http://burningbird.net, and her weblog is Burningbird, at http://weblog.burningbird.net.

Read More Show Less

Read an Excerpt

Chapter 10: Server-Side XML Through VB ASP Components

In this chapter:
XML Basics
Formatting XML
Working with XML in ASP Applications
XML and ADO: Saving Recordsets as XML

There are few technologies that have excited developers as much as XML--Extensible Markup Language. I've heard people talk about XML as a replacement for everything from HTML to SQL. If you view available jobs on the Internet, you'll find few having anything to do with web applications that don't also mention the use of XML in some capacity.

ASP application developers are not immune to the lure of XML, yet there is confusion about how XML can be used with a server-side technology such as ASP, especially when writing ASP components.

This chapter provides an overview of XML, as well as XML formatting techniques, because it's necessary to have an understanding of XML before working on the examples in the second part of the chapter. These examples and their related discussions cover working with XML in ASP components written in Visual Basic. Some of the examples we'll look at include accessing and creating XML through the Microsoft XML parser (MSXML), working with XML through ADO, and mixing ASP processing with XML content.

TIP:  XML is a recommended specification from the World Wide Web Consortium, otherwise known as the W3C. You can access the specification at the W3C web site at http://www.w3.org.

XML Basics

XML is a simple-to-use basic markup language that is a subset of the more complex SGML--or Standard Generalized Markup Language. The specification was created primarily due to insufficiencies of the HTML standard and particularly the difficulties inherent in introducing a new element into the HTML standard.

For instance, mathematicians have a unique professional grammar and syntax that they use to describe their work, but there are no tags within the HTML specification that could be used for this effort. However, to expand HTML just for mathematicians--or musicians, physicists, and so on--isn't efficient.

This problem became very apparent when Netscape began to introduce elements into its rendering of HTML--elements such as FONT for defining font characteristics. By introducing new elements outside of the HTML specification, pages that were created to work with Netscape Navigator didn't work well with Internet Explorer or other browsers.

Another limitation of HTML is that there is an assumed presentation and layout associated with the elements in an HTML document, but not all rendering engines (browsers) provide identical element presentations. The HTML standard just doesn't provide a means of defining every aspect of how an element is shown on the page. A problem associated with combining presentation as well as content within the same specification is that the specification can either become overly large and complex, or pages created using the specification don't always look the same across different browsers, different operating systems, or both.

XML was created as a solution to both of these HTML limitations.

First, XML is a way of creating a document that can contain an arbitrary set of elements--defined with unique element tags--but still be accessible to document parsers that weren't created specifically to work with the page's elements. The reason that parsers can process the page is that the page and the elements follow a specific set of rules.

Secondly, there is no presentation or layout associated with XML elements. This is provided, instead, by separate standards, specifically by Cascading Style Sheets (CSS) or Extensible Stylesheet language (XSL). Separating presentation from content enables anyone to create their own set of XML elements, provide their own presentation with CSS or XSL, and have the page appear the same regardless of what browser parsed the page.

TIP:  This chapter barely touches on the subjects of the XML, CSS, and XSLT specifications--just enough to introduce the examples. For more detailed information, check the XML SDK that's available at the Microsoft web site at http://msdn.microsoft.com/xml.

A Well-Formed XML Document

One reason XML has become so popular is that it's relatively easy to understand the rules governing this markup language. By following the rules, a web developer creates a "well-formed" document that can be parsed by any XML parser, including those built into browsers such as IE, Mozilla, and Navigator 6.0. When the rules aren't followed, the parser can't process the document, and an error results--the parser does not attempt to recover from the error.

TIP:  Another problem with HTML parsers is that they can be very forgiving at times, and web page developers have developed some bad habits as a consequence. A case in point is people using opening tags such as the paragraph (<P>) or list (<LI>) tag in their document but without providing a closing tag for the content.

The first line of an XML document can contain the XML declaration, though this isn't required:


<? xml version='1.0' ?>

This line consists of the XML document tag, in addition to the version of XML used in the document. At this time, there is only one version of XML, but you should use the 1.0 version number to differentiate the XML used in the document from future versions of XML.

The XML declaration can also include the character encoding used in the document, such as UTF-8 or EUC-JP. Not all XML processors can process all encodings, and an error results if you use an encoding the processor doesn't recognize.

All XML elements must either be empty tags or have both beginning and closing tags. For instance, if your XML document has an element such as the following, with attributes but no content, then the element must be defined as an empty tag and have a forward slash at the end of the element:


<template attribute="process" />

If your element defines content, then you'll need to use both a beginning and an ending element tag:


<city>Boston</city>

Not providing either the forward slash for an empty tag or the closing tag results in an XML processor error.

Another XML rule is that any Document Type Definition (DTD) files or rules must be specified before any other element in the document. DTDs provide grammar or additional application-specific rules that can be applied to the XML document. Though not required, providing a DTD file makes the XML document valid as well as well-formed:


<!DOCTYPE template SYSTEM "template.dtd">

An additional rule for the XML document is that the elements contained in it must not overlap. This means that you can nest elements, but a nested element must be closed with the appropriate closing tag (or be an empty tag) before the closing tag of the outer element is reached:


<template>

<inner>

</inner>

</template>

Overlapping elements result in an XML processor error.

XML is case-sensitive, so the case used for the opening tag of an element must match the case used for the closing tag. Otherwise, again, an XML processor error results.

Additionally, there are certain characters that should not be used within attribute values or content, characters such as angle brackets (< and >) or the ampersand (&). These characters have special meaning in XML, just as they do in HTML documents.

Other rules are that element attributes must not repeat within a tag, and they must not reference external entities.

A Valid XML Document

Earlier I mentioned that an XML document with an associated DTD file is considered a valid document. The reason for this is that the DTD file provides the grammar and rules to validate the XML used in the document.

For instance, if an element can contain data, a rule could be added to the DTD file for the XML document, similar to the following:


<! ELEMENT template (#PCDATA)>

As efficient as DTD files are, a problem with them is that the syntax used to define the document grammar differs from the syntax for the XML documents, forcing a person to become familiar with two syntaxes. Efforts are underway to define XML schemas to provide for XML entity and attribute descriptions. XML schemas, unlike DTD files, use XML to describe the XML data.

XML Namespaces

XML is first and foremost extensible. This means that more than one set of XML elements for more than one purpose could be included within the same XML document. However, if the same element name is used with two differing components, you have element collision. To prevent something like this from happening, the W3C provided the XML Namespaces specification in 1999.

Namespaces are identified with URIs and are then used as an alias for elements and element attributes within that namespace. With this approach, a document can contain elements from several difference namespaces, and though the names of the elements are the same, the namespaces prevent collision.

For instance, a namespace could be defined with the following:


xmlns:mine='http://www.somecompany.com/namespc'

And used as is shown in the following:


<mine:book>

...

</mine:book>

No document needs exist at the namespace URI--the URI itself is the key to defining the namespace.

Formatting XML

XML by itself has no presentation or formatting information associated with it. It's used to define elements and their relationships with each other (as in container and contained). Other W3C-recommended specifications are then used to provide formatting, layout, and presentation information about the XML document elements....

Read More Show Less

Table of Contents

Preface
1: Writing ASP Components
The Role ASP Components Play
Why Use ASP Components?
COM+ Services and ASP Components
Accessing Data with ASP Components
Windows 2000 Technologies Accessible from ASP Components
A Rose by Any Other Name: Programming Language Choice
What About ASP.NET?
2: Setting Up the ASP Development Environment
Configuring the IIS Environment
Remote Administration of IIS
Using ADSI to Administer IIS Programmatically
IIS Admin Object Overview
The IIS Base Admin Objects
3: ASP Components and COM
Overview of COM for ASP Component Developers
How COM Is Implemented
Notable COM Interfaces
COM Datatypes
4: ASP Components, Threads, and Contexts
What Are Threads?
Threads and Apartments
The Threading Models
What Are COM+ Contexts?
5: COM+ Services and ASP Components and Applications
Developing Component-Based Systems
The COM+ Interfaces
Porting MTS Packages to COM+ Applications
Activating COM+ Applications
COM+ Services
6: ASP Interaction: Scripting and ASP Components
Scripting Language Support Within ASP
Instantiating Components
COM+ Datatypes and Script/Component Interaction
Passing Arrays as Parameters
Error Handling Between Component and Script
7: Creating a Simple Visual Basic ASP Component
Creating an In-Process or Out-Of-Process Component
Component Instancing
Component Execution and Threads
Creating an ASP Project
Creating Component Methods
Generating, Registering, Installing, and Testing the Component
Adding Support for COM+ Services
Converting MTS Components for Use with COM+
Accessing the ASP Built-in Objects
Error Handling
Debugging
Performance Issues
8: Creating ASP/ADO Components
Accessing ADO from a VB Component
Creating a Simple ADO Component
The ADO Model
File and Directory Access with ADO Streams and the Record Object
Persisting Data
9: Creating an ASP Middle Tier with ADO
How Separate Should the Layers Be?
Creating ADO Data Wrappers
Defining Business Objects
Other Data Integrity Issues
10: Server-Side XML Through VB ASP Components
XML Basics
Formatting XML
Working with XML in ASP Applications
XML and ADO: Saving Recordsets as XML
11: Take a Message: Accessing CDO from ASP Components
A Brief Overview of CDO
The CDO Object Model
Send This URL to a Friend
Working with the Message Body
Retrieving and Reading Messages
12: Working with Active Directory from ASP Applications
A Brief Overview of Active Directory in Windows 2000
Setting Up an Isolated Active Directory Environment
A Refresher on ADSI
Binding to Active Directory Objects
Using the Active Directory Services Viewer
Manipulating Containers
Searching Active Directory with ADO
ASP Example: Add and Manage Users Through the Web
13: Working with MSMQ Components
MSMQ/ASP Basics
Working with Queues
Working with MSMQ Messages
Using Transactions
Journaling
A Brief Word on Message Security
14: Creating C++ ASP Components
ATL or MFC
Using ATL AppWizard to Generate the Basic ASP Component Project
Adding an ATL Object
Code Changes Based on Adding a New Object
Adding Methods to the Interface
Adding Support for COM+ Services
Converting MTS Components for Use with COM+
Accessing the ASP Built-in Objects
Error Handling
15: Adding Data Access to C++ Components with ADO
ADO Access in Visual C++
The ADO Object Model
The Connection Object
The Recordset Object
The IADORecordBinding Interface
The Command Object
Stream and Record Objects
16: The CDO Interfaces from C++ Components
Accessing CDO Interfaces in C++
Creating and Sending a Message
Retrieving and Reading Messages
17: Accessing Active Directory from C++ Components
Binding to Active Directory Objects
ADSI Helper Functions
Filtering Collections
Creating and Removing Active Directory Objects Using ADSI
Searching Active Directory with IDirectorySearch
18: Accessing MSMQ from C++ ASP Components
Adding Support for MSMQ to the C++ Project
Working with Queues
Searching for a Specific Queue
Working with MSMQ Messages
Using Transactions
19: Persistence with ASP Components Using ATL and MFC
Combining MFC and ATL
File Access from ASP Components
Creating a Serializable Class
Persistence Through Object Serialization
20: ASP Components Created with Java
Creating Java Components
Invoking a COM Object in a Java Component
Working with COM+ Services
The ASP Built-in Object and Helper Interfaces
Accessing ADO from Java Components
21: Creating ASP Components with Delphi
Using the COM Wizards to Create ASP Components
Manually Adding Support for COM+/ASP
Working with the ASP Objects
Working with ADO
Working with Windows 2000 Functionality: CDO
22: Perl-Based Components Using ActiveState's PDK
Setting Up PDK
Building a Basic Perl Component
Accessing the ASP Built-in Objects
Working with Data
Working with the Win2K Environment
23: Creating Scripting Language Components
The Windows Script Components Architecture
Elements of a WSC File
Script Components and ADO
The WSC Wizard
Creating Script Components with JScript
Accessing Windows 2000 Functionality
A: ASP Built-in Object Quick Reference
B: The Weaver Database
Index
Read More Show Less

Customer Reviews

Be the first to write a review
( 0 )
Rating Distribution

5 Star

(0)

4 Star

(0)

3 Star

(0)

2 Star

(0)

1 Star

(0)

Your Rating:

Your Name: Create a Pen Name or

Barnes & Noble.com Review Rules

Our reader reviews allow you to share your comments on titles you liked, or didn't, with others. By submitting an online review, you are representing to Barnes & Noble.com that all information contained in your review is original and accurate in all respects, and that the submission of such content by you and the posting of such content by Barnes & Noble.com does not and will not violate the rights of any third party. Please follow the rules below to help ensure that your review can be posted.

Reviews by Our Customers Under the Age of 13

We highly value and respect everyone's opinion concerning the titles we offer. However, we cannot allow persons under the age of 13 to have accounts at BN.com or to post customer reviews. Please see our Terms of Use for more details.

What to exclude from your review:

Please do not write about reviews, commentary, or information posted on the product page. If you see any errors in the information on the product page, please send us an email.

Reviews should not contain any of the following:

  • - HTML tags, profanity, obscenities, vulgarities, or comments that defame anyone
  • - Time-sensitive information such as tour dates, signings, lectures, etc.
  • - Single-word reviews. Other people will read your review to discover why you liked or didn't like the title. Be descriptive.
  • - Comments focusing on the author or that may ruin the ending for others
  • - Phone numbers, addresses, URLs
  • - Pricing and availability information or alternative ordering information
  • - Advertisements or commercial solicitation

Reminder:

  • - By submitting a review, you grant to Barnes & Noble.com and its sublicensees the royalty-free, perpetual, irrevocable right and license to use the review in accordance with the Barnes & Noble.com Terms of Use.
  • - Barnes & Noble.com reserves the right not to post any review -- particularly those that do not follow the terms and conditions of these Rules. Barnes & Noble.com also reserves the right to remove any review at any time without notice.
  • - See Terms of Use for other conditions and disclaimers.
Search for Products You'd Like to Recommend

Recommend other products that relate to your review. Just search for them below and share!

Create a Pen Name

Your Pen Name is your unique identity on BN.com. It will appear on the reviews you write and other website activities. Your Pen Name cannot be edited, changed or deleted once submitted.

 
Your Pen Name can be any combination of alphanumeric characters (plus - and _), and must be at least two characters long.

Continue Anonymously

    If you find inappropriate content, please report it to Barnes & Noble
    Why is this product inappropriate?
    Comments (optional)