You are previewing Designing Active Server Pages.
O'Reilly logo
Designing Active Server Pages

Book Description

Developers of Active Server Pages often reinvent the wheel. Their background in web design, with its separate HTML page for each viewable web page on a site, leads many ASP developers to create a distinct ASP page each time they think they need one. Often times, these pages are functionally similar. With intelligent planning, an ASP developer stands to save a great deal of time by creating reusable ASP pages. Designing Active Server Pages is tailor-made for these developers. There is currently a plethora of Active Server Pages books. However, the vast majority of these books are either technical references or how-to books for beginners. Designing Active Server Pages is written for the intermediate to advanced user. Furthermore, nearly every other book on ASP focuses on using VBScript, even though ASP supports an array of scripting languages, including JScript and PerlScript. Designing Active Server Pages shows how to start using these other languages. The latest version of the scripting engines (Version 5.1 for VBScript) adds new features not available before the 5.0 release. These features include class support for VBScript, and Regular Expression searching through the use of a COM object. Designing Active Server Pages explains why using classes in VBScript is beneficial, and demonstrates the power of regular expression searching. This book shows how to simplify the process by only requiring one ASP page to handle ALL of the Forms throughout a web site, thus reducing the amount of code one has to write. Topics include:

  • Using various Microsoft and third-party components to enhance ASP pages

  • Creating components using VB and/or VC++

  • Sample code for performing routine ASP tasks

  • Techniques to allow for reusable database scripts on the database system and on ASP pages

  • How to obtain and register third-party components, thus saving massive amounts of time by reusing someone else's code

Designing Active Server Pages is for developers who have already mastered the basics of ASP application development and are ready to take the next logical step. It is sure to become an indispensable part of every web developer's library.

Table of Contents

  1. Designing Active Server Pages
    1. Preface
      1. Who This Book Is For
      2. How This Book Is Organized
      3. ASP Information on the Web
      4. Obtaining the Sample Code
      5. Conventions Used in This Book
      6. How to Contact Us
      7. Acknowledgments
    2. 1. Introduction
      1. What Is Application Design?
        1. Designing for the Web
      2. What’s Wrong with ASP Design?
      3. Why Hasn’t ASP Design Advanced?
      4. What Can Be Done to Improve ASP Design?
        1. Server-Side Includes
          1. File types that can perform server-side includes
          2. Dynamic server-side includes
          3. Naming your include files
          4. Protecting the contents of your include files from prying eyes
          5. More about server-side includes
        2. VBScript Classes
        3. Using Server.Execute
        4. Using Server.Transfer
      5. Further Reading
    3. 2. Choosing a Server-Side Scripting Language
      1. The Popularity of VBScript
      2. Specifying the Scripting Language
        1. Specifying the Server-Side Scripting Language with SCRIPT Blocks
        2. Choosing the Right Scripting Language
      3. Creating ASP Pages with JScript
        1. Statement Termination
        2. JScript’s Variables and Datatypes
        3. Case Sensitivity
        4. Regular Expressions
        5. Error Handling
        6. An ASP Example Using JScript
      4. Creating ASP Pages with PerlScript
        1. PerlScript’s Variables and Datatypes
        2. Case Sensitivity and Object Reference
        3. Reading and Writing Files with PerlScript
        4. Regular Expressions
        5. Other PerlScript Features
        6. An ASP Example Using PerlScript
      5. Creating ASP Pages with Python
      6. Further Reading
    4. 3. Exception Handling
      1. A Bit of Terminology
      2. Detecting When Exceptions Occur
        1. Detecting Exceptions with Scripting Language Error-Handling Mechanisms
          1. Detecting errors with VBScript
          2. Deciding when to check if an exception occurred
          3. Error handling in functions and subroutines
          4. Streamlining VBScript error-handling code
          5. Detecting errors with JScript
          6. Nested try ... catch blocks
          7. VBScript’s error handling versus JScript’s error handling
        2. Detecting Exceptions with the ASPError Object
          1. Scripting language errors
          2. Detecting compile-time errors with the ASPError object
          3. Internal ASP errors
          4. External COM object errors
      3. Responding to Exceptions
        1. Displaying an Understandable Error Message
        2. Notifying the Support Team When an Error Occurs
          1. Notifying the support team with scripting language error-handling techniques
          2. Notifying the support team with the ASPError object
        3. Recovering from an Error
      4. Creating Custom HTTP Error Pages
      5. Further Reading
    5. 4. Regular Expressions, Classes, and Dynamic Evaluation and Execution
      1. Using the RegExp Object
        1. RegExp’s Properties
        2. Legal Regular Expression Syntax
        3. RegExp’s Methods
      2. Using Object-Oriented Programming with VBScript
        1. Object-Oriented Programming 101
          1. An object and an instance
          2. Encapsulating complexity
        2. Using Classes in VBScript
          1. Creating classes
          2. The Initialize and Terminate events
          3. Properties, methods, member variables, and member functions
          4. The public and private statements
          5. Using Property Get
          6. Using Property Let
          7. Using Property Set
          8. Creating read-only or write-only properties
        3. Creating Useful, Reusable Code
      3. Using Dynamic Evaluation and Execution
        1. Dynamic evaluation
        2. Dynamic execution
      4. Further Reading
    6. 5. Form Reuse
      1. The Importance of Code Reuse
        1. Code Reuse in ASP
          1. Examining form usage
      2. A Primer on Form Use
        1. Creating HTML Forms
          1. The building blocks of forms
        2. Processing Forms Through an ASP Page
          1. Working with the QueryString and Form collections
      3. Form Validation
        1. Client-Side Form Validation
        2. Server-Side Form Validation
      4. Creating Reusable Server-Side Form Validation Routines
        1. Using Classes to Enhance Server-Side Validation
          1. Further enhancements to the server-side validation class
      5. Developing Reusable Form Creation Routines
        1. Form Implementation Complexity
        2. Masking Implementation Complexity Using Classes
      6. The Practicality of Reuse
      7. Further Reading
    7. 6. Database Reuse
      1. Examining Database Usage
      2. The Building Blocks for Creating Reusable Administration Pages
        1. The Ideal Reusable Administration Page Script
        2. Database Schemas
          1. Importing enumerations with
          2. Importing enumerations with the METADATA tag
          3. Opening schemas
          4. The Criteria parameter
      3. Creating Reusable Administration Pages
        1. A Review of Database Terms
          1. Primary key constraints
          2. AutoNumber columns
          3. Foreign key constraints
        2. Gathering Column Information
          1. The ColumnInformation class
          2. The Columns class
          3. Columns’s class properties and member variables
          4. Columns’s class methods
          5. Testing the Columns and ColumnInformation classes
        3. Gathering Foreign Key Information
          1. The ForeignKeyInformation class
          2. The ForeignKeys class
          3. Testing the ForeignKeys and ForeignKeyInformation classes
        4. Deciding How to Display the Table Columns in a Form
          1. The DataTypeFormElementInformation class
          2. DataTypeFormElementInformation’s other methods
          3. Testing the DataTypeFormElementInformation class
        5. Creating the Administration Page Forms
          1. The AdminPageGenerator class
          2. The AdminPageGenerator member variables and properties
          3. The AdminPageGenerator methods
          4. The “Insert a New Record” administration page
          5. The “Delete an Existing Record” administration page
          6. The “Edit an Existing Record” administration page
        6. Inserting, Updating, and Deleting Database Records
          1. The ModifyDatabase class’s properties and event handlers
          2. ModifyDatabase’s methods
          3. Inserting a record into the database
          4. Selecting a particular record to edit
          5. Editing an existing database record
          6. Deleting an existing database record
        7. Tying the Administration Pages Together
          1. MenuItem’s methods, properties, and event handlers
          2. Testing the MenuItem class
          3. AdminPageMenu’s properties and event handlers
          4. AdminPageMenu’s methods
          5. Generating a menu with the AdminPageMenu and MenuItem classes
          6. /CODEREUSE/DisplayAdminPage.asp: the single administration page form generation script
        8. Limitations and Possible Enhancements
          1. A note on performance
      4. Further Reading
    8. 7. Using Components
      1. COM—A Quick Overview
      2. Lesser-Known Microsoft COM Components
        1. Creating a Random Banner Rotation System with Ad Rotator
          1. Creating a rotator schedule file
          2. Displaying a banner
          3. The redirection file
          4. Tracking banner statistics
          5. Providing impression and click-through tracking via a class
          6. Using the AdRotation class
          7. Possible enhancements to the AdRotation class
          8. Did we really accomplish anything?
        2. Managing Web Site Content with the Content Linker
          1. The Content Linker list file
          2. Providing a next and previous hyperlink in each tutorial
          3. Creating an index listing of the JScript Control Structure tutorials
      3. Enhancing Microsoft’s COM Components
      4. Building Components
        1. Wrapping Business Logic Within a COM Object
        2. Using COM Objects in a Multienvironment Scenario
        3. Building COM Components with Script
          1. Dissecting the Windows Script Component file
          2. Windows Script Components versus classical, binary COM components
      5. Further Reading
    9. 8. Enhancing Your Web Site with Third-Party Components
      1. Executing DOS and Windows Applications on the Web Server with ASPExec
        1. ASPExec’s Properties and Methods
        2. Executing a Command-Line Program with ASPExec
      2. Obtaining Detailed Information About Your Users’s Browsers
        1. Using Microsoft’s Browser Capabilities Component
        2. A More Versatile Solution: cyScape’s BrowserHawk
          1. Using the BrowserHawk component
          2. Redirecting users based on their browser’s enabled capabilities
      3. Grabbing Information from Other Web Servers
        1. ASPHTTP’s Properties and Methods
        2. Retrieving a Web Page with ASPHTTP
        3. Retrieving Binary Data with ASPHTTP
      4. Encrypting Information
        1. Encrypting Information with a Key
          1. Symmetric cryptography
          2. Asymmetric cryptography
        2. Authentication
        3. Digital Certificates
          1. Client and server certificates
        4. Sending Digitally Signed, Encrypted Email with ASPEncrypt
          1. Obtaining the client’s certificate
          2. Sending encrypted email
          3. Sending digitally signed emails
          4. Sending digitally signed, encrypted email
      5. Uploading Files from the Browser to the Web Server
        1. Creating a Simple “Upload a File” ASP Page
        2. Uploading Binary Objects to a Database
          1. Displaying a property’s pictures
        3. Other SA-FileUp Features
      6. Why Reinvent the Wheel?
      7. Further Reading
    10. Index
    11. Colophon