000 27088nam a22001457a 4500
999 _c5826
_d5826
020 _a9780789713896
082 _a004.36
_bJOH
100 _aJohnson, Scot | Ballinger, Keith | Chapman, Davis
245 _aUsing active server pages
250 _aSpecial Edition
260 _aIndianapolis;
_bQUE -
_c1997.
300 _axix,811p.
505 _aTable of Contents Introduction 1 2 The Purpose of This Book Who Should Use This Book 2 How the Book Is Organized 3 Part 1 Introduction to Active Server Pages 3 Part II VBScript: The Foundation of Active Server Pages 3 Part III Active Server Objects: The Essential Building Blocks 3 Part IV Active Server Components 4 Part V Database Management with Active Server Pages 4 Part VI Active Server Pages and the Enterprise Solution 4 Conventions Used in This Book 4 I Introduction to Active Server Pages 1 Getting Started with Web Enabling: Creating Dynamic Applications with Active Server Pages 9 Static versus Dynamic Content 10 Static Content 10 Dynamic HTML. Content 10 Designing and Deploying Web-Enabled Applications: A Changing Architecture for Changing Needs 12 The Web Browser 13 The Web Server 14 The HTTP-TCP/IP Connection 14 The Database Server 15 Proxy Servers 16 Firewalls 17 Certificate Servers 17 External Servers 18 The Evolution of Active Server Pages 18 Common Gateway Interface 18 Internet Server Application Programming Interface 19 The HTML Object Model 20 Dynamic HTML Object Model 22 Active Server Pages and The Active Server Model: A COM-Based Evolution 23 The Composition of Active Server Pages 24 From Here... 27 2 Developing and Deploying Active Server Page Applications 29 Planning Active Server Web Sites and Applications 30 Why Use Components? 30 Why Use Transactions? 32 Creating Active Server Pages 34 Visual Inter Dev 34 FrontPage 35 ActiveX Scripting Languages: Linking It All Together 36 VBScript 36 JavaScript 36 JScript 36 Scripting Tools 37 Microsoft Script Wizard and the Script Debugger 37 Visual JavaScript 38 The Internet Information Server 39 The Microsoft Management Console 39 Secure Socket Layer 3.0 and Client Authentication 41 HTTP 1.1 Support 42 Server-Side Java 43 Extending Active Server Pages into Client/Server 44 Your Existing Network 43 Terminal Access 44 N-Tier Client/Server 44 Web Access 45 N-Tier Web Access 45 From Here... 45 II VBScript: The Foundation of Active Server Pages 3 VBScript Programming Basics: Variables and Scope 49 What Is VBScript? 50 VBScript's History 51 Extending Functionality on the Web Client and Web Server 52 Communication Between Objects and Events 52 Differences Between VBA, VB, and VBScript 55 Server and Client-Side Syntax 57 Security 58 VBScript Variable Datatypes 60 Variant 60 Subtypes 60 Identifying the Datatype 62 Using Variables 62 Variable Scope 62 Declaring Variables 64 Declaration Limitations 66 From Here... 66 4 Working with Operators 69 Arithmetic Operators 70 Addition 70 Subtraction 72 Multiplication 72 Division 72 Exponentiation 72 Integer Division Operator 73 Modulus Operator 74 Comparison Operators 75 Equality Comparison 77 Inequality Comparison 78 Greater Than Comparison 78 Less Than Comparison 78 Object Comparison 79 Logical Operators 79 Negation (NOT) 80 Conjunction (AND) 81 Disjunction (OR) 82 Exclusion (XOR) 82 Equivalence (EQV) 83 & Operator 84 Concatenation Operators 84 + Operator 85 Operator Precedence 85 From Here... 87 5 Controlling Program Flow with VBScript 89 Using Decision Structures 90 The If... Then Condition 90 The If... Then... Else Statement 91 The Select Case Statement 94 Implementing Looping Logic 96 The For... Next Statement 96 The Do... Loop Statement 99 The While... Wend Statement 100 The For Each... Next Statement 101 Interrupting the Program Flow 101 The Exit Statement 102 The On Error Statement 103 Error Trapping with the Err Object 104 The Err Object's Properties Using the Err Object Methods 107 108 From Here... 109 6 Working with Functions, Subroutines, and Dialog Boxes 111 Introducing Event-Driven Programming 112 Using Procedures: Subroutines and Functions 114 Subroutines 118 General Procedure Rules 114 Functions 119 Using Dialog Boxes to Interact with Users 120 Message Box 120 Input Box 125 From Here... 126 7 Datatype Conversion Features 127 Identifying the Datatype 127 The IsArray Function 128 The ItDate Function 128 The IsEmpty Function 129 The IsNull Function 129 The IsNumeric Function 131 The IsObject Function 131 The VarType Function 132 The Formatting Functions 133 The FormatDateTime Function 133 The FormatCurrency Function 134 The FormatPercent Function 135 The FormatNumber Function 136 Datatype Conversions 136 Chool Function 137 CByte Function 138 CCur Function 138 CDate Function 139 CDbl, Cint, CLng, CSng 139 CStr Function 140. From Here... 141 8 Putting It All Together with VBScript 143 Application Overview 144 Creating Server-Side Active Server Scripts with VBScript. 146 Creating the Visual InterDev Project 147 Building Data Retrieval and Display 150 Processing the Logic 153 Minor Error Trapping 155 Creating Client-Side VBScript 155 Building the Validation Subroutine 157 Restructuring the HTML 156 Testing for a VBScript-Compliant Browser 158 From Here... 159 9 Using the Script Debugger 161 Using the Script Debugger 162 Managing the Script Components 165 Controlling Script Flow 167 Types of Errors 172 Runtime Errors 173 Syntax Errors 173 Logical Errors 174 From Here... 175 III Active Server Objects: The Essential Building Blocks 10 The Composition of an Active Server Application 179 The Components of an Active Server Page Application 180 Text Files 180 Physical, Root, and Virtual Directories 181 ASP Scripting Languages and HTML 182 The Active Server Page Project File: GLOBALASA 184 Tracking Application Events 186 Tracking Session Events 187 Activating the GLOBALASA File 187 Understanding Scoping Issues in Active Server Applications 189 GLOBALASA Scoping Level Application-Level Scope 190 190 Session-Level Scope 191 Procedure-Level Scope 191 The Fundamental Active Server Page Objects 192. The Application Object 192 The Server Object 192 The ObjectContext Object 192 The Session Object 193 The Response Object 193 The Request Object 193 Debugging Active Server Pages 193 Trapping Errors with the Err Object 194 Trapping Errors with the Web Server Log File 195 Trapping Errors by Writing Text Files 195 Controlling Access to the Site 197 Web Server Packet Filtering 197 File Level Access Control 198 Configuring Active Server Pages 199 The Metabase 199 The Registry Settings 201 Web Server Interface Utilities 204 Using ASP Directives 205 Handling Known Active Server Page Issues 208 From Here... 209 11 Controlling the Application: The Application Object 211 Trapping Application Events Declaring Application-Level 212 Variables 214 Application OnStart Event 217 Application OnEnd Event 217 Controlling Application Level Variables with Methods 218 Lark Method 218 Unlack Method 219 Using Components at the Application Level 220 Instantiating Application-Level Objects 220 Level 222 Using Arrays at the Application The Application Collection 220 The Contents Collection 225 The StaticObject Collection 22 From Here... 228 12 Controlling the Server with the Server Object and Using Transaction Processing with the ObjectContext Object 229 Controlling the Server Object Using Methods 230 Expanding the Web Server with the CreateObject Method 230 Managing Server Information with MapPath 232 Using the Server Encoding Methods 234 Using the URLEncode Method 235 Using the HTMLEncode Method 237 The Server Object Properties 237 Using the ObjectContext Object for ASP Transaction Processing 239 Configuring the MTS components 239 Setting Up ASP to Support Transactions 240 Controlling Success and Failure with Methods 240 The SetComplete Method 241 The SetAbort Method 241 Trapping the ObjectContext's Events OnTransaction Commit Event 242 242 On Transaction Abort Event 243 From Here... 244 13 Managing the User Session: The Session Object 247 Using Session Variables to Track User Workflow 248 Identifying the User 248 The Problem with Cookies 249 Implementing Session Variables and Properties 250 Declaring Session Variables 251 The SessionID Property 252 The Timeout Property 252 The LCID Property 254 The CodePage Property 256 Trapping Session Events 256 Session OnStart 256 Session OnEnd 258 Controlling User Session Resources 259 The Abandon Method 259 Configuring the Session Object 261 Using Session-Level Objects 261 Instantiating Session-Level Objects 261 Instantiating Session-Level Objects 262 Storing Arrays in the Session Object 262 Managing Session Variables Using Collections 264 The Contents Collection 265 The StaticObject Collection 265 From Here... 266 267 14 Speaking to the Web Client: The Response Collection The Response Collection 268 The Expires Attribute 270 The Domain Attribute 271 The Path Attribute 272 The Secure Attribute 272 The HasKeys Attribute 272 Using the Response Object's Properties 273 The Buffer Property 274 The CacheControl Property 276 The CharSet Property 277 The ContentType Property 280 The Expires Property 280 The ExpiresAbsolute Property The PICS Property 281 281 The Status Property 283 The IsClientConnected Property 284 Sending Output to the Browser. The Response Methods 284 The Write Method 285 The AddHeader Method 289 The AppendToLog Method The BinaryWrite Method 290 289 The Clear Method 290 The End Method 291 The Fluch Method 292 The Redirect Method 293 From Here... 295 15 Retrieving User Information: The Request Object 297 Understanding the Request Object 298 Accepting User Information Using the Request Collections 299 The ClientCertificate Collection 300 Retrieving Cookie Information Using the Cookies Collection 301 The Form Collection 303 The QueryString Collection 305 The ServerVariables Collection 309 The Request Properties and Methods 313 The TotalBytes Property 313 The BinaryRead Method 313 From Here... 314 16 Putting It All Together: Building an Online Catalog 315 The ASP Online Catalog Application: An Overview 316 Pre-Loading Application Variables Using the GLOBALASA 318 Creating Application-Level Variables and Arrays 318 Creating the User's Shopping Basket Using Session-Level Arrays and Variables 320 Creating and Managing Active Server Pages and Workflow 321 Accessing Application-Level Arrays 321 Using the Server Object's Encoding Techniques 324 Using ASPs as Non-Visual Code Libraries 325 Examining the Shopping Basket 326 Using the Request Object in a Maki-Button Form 328 Extracting Information Using the Request Object 329 From Here... 330 IV Active Server Components 17 Implementing Existing Server-Side Components 335 The Ad Rotator Component 336 The GetAdvertisement Method 336 The Ad Rotator Component Required Files 337 The Rotator Schedule File 338 The Redirection File 339 The Ad Rotator Properties 340 The Browser Capabilities Component 342 The BROWSCAP.INI File 342 The Browser Capabilities Component Properties 345 The Database Access Component 347 Component 348 The Active Messaging/SMTP The Tools Component 354 The FileExists Method 354 The Owner Method 356 The Randem Method 357 356 The Flaugin Erists Method 357 The Permission Checker Component The HasAccess Method 358 The Content Linking Component 360 The NextLink Files 360 The Content Linking List 361 The Content Linking Methods 362 The Content Rotator Component 371 The Content Schedule File 371 The Content Rotator Methods 373 The Choose Content Method 373 The GetAllContent Method 374 The Page Counter Component 375 The Page Counter Component Methods 376 The Hits Method 377 The Reset Method 377 The Counter Component 378 The Get Method 379 The Increment Method 380 The Set Method 380 The Remove Method 381 From Here... 381 18 Creating Your Own Active Server Components 383 Creating ActiveX Components 384 Dealing with Datatype Differences Wrapping Built-In Visual Basic 389 Functions 392 Encapsulating Complex Calculations 394 Porting Existing Applications 398 Accessing the ASP Intrinsic Objects from Within an ActiveX Component 401 Speeding Up Your ASP Program 405 From Here... 408 19 Putting It All Together: Creating an Online Registration System 409 Rotating the Content with the Content Rotator Component 411 Rotating the Banner with the Ad Rotator Component 414 Verifying that a File Exist with the Tools Component 415 Detecting the Browser with the Browser Capabilities Component 417 Determining Page Hits with the Page Counter Component 419 Build a Web Registration with the Content Linker 420 From Here... 425 V Database Management with Active Server Pages 20 Database Access with ADO 429 Understanding ADO 430 OLE DB 430 Web Application Development 431 Products for Web Development 432 The ADO Object Model 432 Properties and Methods of ADO Objects 433 ADO in Action 443 Benefits of Coding with the ADO Object Model 445 Transaction and Rollback Processing 446 Remote Data Services 447 Creating a Simple Data-Driven ASP Program 448 From Here... 449 21 Working with ADO's Connection Object 451 Properties and Methods of the Connection Object 452 Connection Object Properties 452 Connection Object Methods 453 Linking to Your Data with the Connection Object 454 Configuring the Connection Object 456 Controlling the Connection 459 Error Handling with ADO 463 The Properties and Methods of the Error Collection 463 The Properties of the Error Object 463 The Command Object and the Connection Object 465 Revisiting the Employee Phone Application 465 From Here... 467 22 Using Command Objects 469 The Command Object 470 Creating a Command Object 470 Properties and Methods of the Command Object 471 Using the Command Object to Access Data 475 The Parameters Collection and the Parameter Object 476 Methods and Properties of the Parameters Collection 476 Methods and Properties of the Parameter Object 477 Parameters in Action 480 Revisiting the Phone Application 481 From Here... 482 23 Working with ADO's Recordset Object 485 Retrieving Data into a Recordset 486 Isolation 486 Locking 487 Identifying Cursor Types 487 Recordset Properties 489 BOF/EOF 490 RecordCount 491 Absolute Position 492 Filter 493 Absolute Page 492 Navigating the Recordset 495 MoveFint 495 Movelast 495 MoveNext 496 Move Previous 497 Manipulating the Recordset 498 Update 498 AddNese 499 Delete 500 Supports 500 The Recordset in Action 500 From Here... 504 24 Managing Your Database 505 Understanding Databases 506 Types of Databases 506 SQL 507 Client/Server Development 509 Transaction Processing with Transaction Server 510 Transactions 511 Inside Transaction Server 511 Concurrency Issues 512 ODBC 3.0 513 Designing and Configuring Databases 514 Data Modeling 514 Keys and Indexes 517 Data Access 518 Database Security 519 From Here... 519 25 Accessing Databases with Remote Data Services 521 522 Understanding Remote Data Services Creating Business Objects 523 Understanding IE 4 and Dynamic HTML 524 Active Server Pages and RDS 524 Using the RDS Components 524 Advanced Data Virtual Table Manager 524 AdvancedDataControl Object 525 Advanced Data Space Object 526 Advanced Data Factory Object Understanding the Limitations 526 of RDS 527 Extending the Phone Book Application 527 From Here... 534 V 26 Putting It All Together: Creating a Dynamic Database Application 535 Loading the Products Table 536 Create the ActiveX Data Object Connection 536 Modifying the Inventory Database 540 Deleting Items from the Inventory 540 Adding Records to the Database 542 Using Visual InterDev to Access Using Visual InterDev's Design Data the Data 543 Control to Retrieve Records 543 Using the Visual InterDev Forms Wizard to Create the Product Administration Interface 551 Controlling Access to the Site 555 From Here... 557 VI Active Server Pages and the Enterprise Solution 27 Visual InterDev: The Active Server Pages Integrated Development Environment 561 A Development Environment for Active Server Pages 562 An Introduction to Visual Inter Dev 562 Creating Projects and Workspaces 563 The Visual InterDev Environment 565 Visual Database Tools 569 The Integrated Data View 569. The Query Designer 570 The Database Designer 572 Data Form Wizards 573 Database Design-Time Controls 574 Productivity Features 575 The Script Wizard 576 The Visual InterDev Editor 577 HTML Layout Control Editor 578 Microsoft Image Composer 581 Microsoft Music Producer 582 Microsoft Media Manager 582 From Here... 583 28 Working with the Microsoft Transaction Server 585 Understanding Distributed Transaction Processing 587 Transaction Monitors 589 Object Request Brokers 591 Introducing Microsoft Transaction Server 592 Managing Database Connections 593 Managing Distributed Objects 595 Transaction Coordination 596 Integrating Active Server Pages with Transaction Server 597 Registering Components with Transaction Server 597 Creating Transaction Server Components 603 Calling Component Methods 604 Returning Data from Components 604 The Account Components 605 Calling the Account Components from ASP 606 Building Transaction Server Components for Use with Active Server Pages 610 Threading and Transaction Server Components 610 Parameter Passing with Active Server Pages 611 From Here... 612 29 Working with the Message Queue Server 613 What Is Message Queuing? 614 Guaranteed Message Delivery 615 Store and Forward 616 Queue Browsing 617 Message Prioritizing and Aging 617 Transactional Messages 618 Journal and Dead-Letter Queues 618 Microsoft's Message Queue Server 619 ActiveX Components 619 Creating Queues 620 Locating Queues 622 Opening Queues 624 Sending Messages 625 Receiving Messages 628 Closing Queues 628 Deleting Queues 628 Message Queue Server and Active Server Pages 629 Creating a Message Queue 629 Sending a Message to the Queue 631 Receiving the Message from the Queue 634 Closing and Deleting the Queue 636 From Here... 637 30 Application Development for the Corporate Intranet/Extranet 639 Developing Intranet Applications 640 Leveraging Bandwidth 640 When You Know What Browser They Have... 641 Sample Applications for the Intranet 643 Project Management Tool 643 Building an Extranet 649 Securing Your Extranet from Intruders 649 From Here... 651 Confidential Information 650 31 Using Internet Information Server 4.0 to Manage Your Web Applications 653 The Microsoft Management Console 654 Network Service Management 654 Web Site Management 656 Configuring Active Server Application Settings 661 Setting Security Accounts 664 Creating New Sites and Virtual Directories 666 Changing the Default Site Values 667 New Active Server Pages Functionality 668 The Script Debugger 668 Transactional Scripts, Microsoft Transaction Server, and Isolated ASP Applications 668 New ASP Components 670 Utilizing New HTTP 1.1 Support 670 From Here... 671 32 Putting It All Together: Creating an N-Tier Online Catalog Application 673 Create the Application Initialization Component 674 Creating the Customized Database Access Component 675 Registering the Component 678 Installing Components on the Microsoft Transaction Server 678 Using the Regsrv32 and DCOMCFG Utilities for Component Configuration 682 Integrating the New ActiveX Components into the ASPs 684 Calling the Component from the Active Server Page 684 Creating the Generic Error Form 685 Creating the Validation Server 686 Inventory Control Database Creating the Order Processing and Component 688 Creating the GetProductInventory Method 688 Creating the AddProductInventory Method 689 Creating the Delete ProductInventory Method 690 Building and Testing Components 691 Putting It All Together. Filling the Order 693 From Here... 695 Appendixes A VBScript 2.0 Reference 699 Scripting Active Server Pages 700 Operators 703 Statements and Conditional Statements 704 Intrinsic Functions 705 The Abs() Function 710 The Array() Function 710 The Ase() Function 710 The Atn() Function 710 The CBool() Function 710 The Chyte() Function 711 The COur Function 711 The CDate Function 711 The CDMO Function 711 The Chr() Function 711 The Clnt) Function 711 The CLng() Function 711 The Cos() Function 712 The CreateObject() Function 712 The CSng Function 712 The CStr() Function 712 The Date Function 712 The DateAdd() Function 712 The DateDiff() Function 713 The DatePart() Function 713 The DateSerial() Function 713 The DateValue() Function 714 The Day() Function 714 The Exp() Function 714 The Filter() Function 714 The Fir() Function 714 The FormatCurrency() Function 714 The FormatDateTime Function 715 The FormatNumber() Function 715 The Format Percent() Function 715 The Hex() Function 715 The Hour() Function 716 The InputBox() Function 716 The InStr() Function 716 The InStrRev() Function 716 The Int() Function 716. The IsArray() Function 717 The IsDate() Function 717 The IsEmpty() Function 717 The IsNull() Function 717 The IsNumeric() Function 717 The IsObject() Function 717 The Join() Function 718 The LBound() Function 718 The LCase Function 718 The Left() Function 718 The Len Function 718 The LoadPicture() Function 718 The Log() Function 719 The LTrim Function 719 The Mid() Function 719 The Minute() Function 719 The Month Function 719 The MonthName() Function 719 The MsgBox() Function 720 The Now Function 720 The Oct Function 720 The Replace() Function 720 The Right() Function 720 The Rnd() Function 721 The Round Function 721 The RTrim Function 721 The ScriptEngine() Function 721 The ScriptEngine Build Version () Function 721 The ScriptEngine MajorVersion() Function 721 The ScriptEngine MinorVersion() Function 722 The Second() Function 722 The Sgn() Function 722 The Sin Function 722 The Space Function 722 The Split() Function 722 The Sqr Function 723 The StrComp Function 723 The StrReverse() Function 723 The String() Function 723 The Tan() Function 723 The Time Function 723 The TimeSerial() Function 724 The TimeValue() Function 724 The Trim() Function 724 The TypeName Function 724 The UBound() Function 724 The UCase() Function 724 The VarType Function 725 The Weekday() Function 725 The WeekdayName() Function 725 The Year() Function 725 Constants 725 Color Constants 725 Comparison Constants 726 The Date/Time Constants 726 Date Format Constants 727 File Input/Output Constants 728 Miscellaneous Constant 728 The MsgBor Constants 728 String Constants 730 Tristate Constants 730 VarType Constants 731 VBScript Objects 732 VBScript Object Methods 732 VBScript Object Properties 733 B Active Server Object Reference 735 Controlling the Application Object 736 Declaring Application-Level Variables 736 Controlling Application-Level Variables with Methods 737 Instantiating Application-Level Objects 738 Controlling the Server Object 738 The CreateObject Method The MapPath Method 739 739 The ScriptTimeOut Property 739 Using Server Encoding Techniques 740 The URLEncode Method 740 Using the HTMLEncode Method 740 The ObjectContext Object: Interacting with the Transaction Server 741 The SetComplete Method 741 The SetAbort Method 741 Trapping the ObjectContext's Events 741 The On TransactionCommit Event 742 OnTransaction Abort Event 743 Communicating with Web Client: The Response Object 743 The Response Collection 744 The Cookies Collection 744 The Response Object's Properties 745 Sending Output to the Browser. The Response Methods 747 The Write Method 748 The AddHeader Method 748 The AppendToLog Method 748 The Clear Method 749 The BinaryWrite Method 749 The End Method 749 The Flush Method 749 The Redirect Method 749 Retrieving Information Using the Request Object 750 Accepting User Information Using the Request Collections The Request Properties and 750 Methods 754 Managing the Session Object 754 The Session Object: A Cookie-Dependent System 755 Implementing Session Variables and Properties 755 Declaring Session Variables Trapping Session Events 757 Controlling User Session 756 Resources 758 Using Session-Level Objects 761 C ADO Reference Connection Object 762 759 Properties 762 Methods 763 Errors Collection and Object 765 Properties 765 Command Object 765 Properties 765 Methods 766 Parameters Collection and Objects 767 Properties 767 Methods 768 Recordset Object 768 Properties 768 Methods 770 Fields Collection and Objects 773 Properties 773 Methods 773 D Active Server Component Reference 775 Ad Rotator Component 776 Properties 776 Methods 776 Files 776 Browser Capabilities Component 777 Files 777 778 Content Linking Component Methods 778 Files 779 File Access Components 779 FileSystemObject 779 Properties 779 TextStream 780 Index 783
942 _cREF