 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 33 - Active Server Pages (ASP) Outline 33.1 Introduction 33.2 How Active Server Pages Work 33.3.

Slides:



Advertisements
Similar presentations
 2004 Prentice Hall, Inc. All rights reserved. Chapter 23 – ASP.NET Outline 23.1 Introduction 23.2.NET Overview NET Framework ASP (Active.
Advertisements

1 Active Server Pages (ASP) Dr. Awad Khalil Computer Science Department AUC.
DT228/3 Web Development WWW and Client server model.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
 2003 Prentice Hall, Inc. All rights reserved. Chapter 21 – Web Servers (IIS and Apache) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3 System.
1 Chapter 12 Working With Access 2000 on the Internet.
Session 6 Server-side programming - ASP. An ASP page is an HTML page interspersed with server-side code. The.ASP extension instead of.HTM denotes server-side.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
1 Active Server Pages Active Server Pages (ASPs) are Web pages ASP = server-side scripts + HTML The appearance of an Active Server Page depends on who.
 2001 Prentice Hall, Inc. All rights reserved. 1 Active Server Pages (ASP)
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
 2004 Prentice Hall, Inc. All rights reserved. Chapter 25 – Perl and CGI (Common Gateway Interface) Outline 25.1 Introduction 25.2 Perl 25.3 String Processing.
Form Handling, Validation and Functions. Form Handling Forms are a graphical user interfaces (GUIs) that enables the interaction between users and servers.
McGraw-Hill/Irwin © 2004 by The McGraw-Hill Companies, Inc. All rights reserved. Beginning Active Server Pages Barry Sosinsky Valda Hilley Programming.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Database Processing. Web Database Applications Static Report Publishing a report is prepared from a database application and exported to HTML DB.
INTRODUCTION TO WEB DATABASE PROGRAMMING
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
1 Web Server Concepts Dr. Awad Khalil Computer Science Department AUC.
Dr. Azeddine Chikh IS444: Modern tools for applications development.
Comp2513 Forms and CGI Server Applications Daniel L. Silver, Ph.D.
Active Server Pages (ASP) 1. 2 Introduction Active Server Pages (ASP) –Server-side text file –Processed in response to client request –Pages are processed.
Tutorial 10 Adding Spry Elements and Database Functionality Dreamweaver CS3 Tutorial 101.
JavaScript, Fourth Edition
Using Visual Basic 6.0 to Create Web-Based Database Applications
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 21 - Web Servers (IIS, PWS and Apache) Outline 21.1 Introduction 21.2 HTTP Request Types 21.3.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Web Design and Development for E-Business By Jensen J. Zhao Copyright 2003 Prentice Hall, Inc. Web Design and Development for E-Business Jensen J. Zhao.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
Chapter 8 Cookies And Security JavaScript, Third Edition.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
 2004 Prentice Hall, Inc. All rights reserved. 1 Segment – 6 Web Server & database.
2-1 WEB DATABSE INTERFACING Colorado Technical University IT420.
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
Web Pages with Features. Features on Web Pages Interactive Pages –Shows current date, get server’s IP, interactive quizzes Processing Forms –Serach a.
ASP. What is ASP? ASP stands for Active Server Pages ASP is a Microsoft Technology ASP is a program that runs inside IIS IIS stands for Internet Information.
 2008 Pearson Education, Inc. All rights reserved JavaScript: Introduction to Scripting.
 2001 Prentice Hall, Inc. All rights reserved. 1 Chapter 25 - Active Server Pages (ASP) Outline 25.1 Introduction 25.2 How Active Server Pages Work 25.3.
 2001 Prentice Hall, Inc. All rights reserved. Chapter 7 - Introduction to Common Gateway Interface (CGI) Outline 7.1Introduction 7.2A Simple HTTP Transaction.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
ASP (COMPONENTS) Active Server Pages (cont..) 1. global.asa file The Global.asa file is an optional file that can contain declarations of objects, variables,
WEB SERVER SOFTWARE FEATURE SETS
Database Connectivity and Server-Side Scripting Chapter 12.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 14 Web Database Programming Using PHP.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
ASP.NET Part II Dr. Awad Khalil Computer Science Department AUC.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
27.1 Chapter 27 WWW and HTTP Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
1 Active Server Pages (ASP) Outline FSO Introduction File System Object File System Object Methods Active Server Page File System Folder Objects Simple.
1 Chapter 1 INTRODUCTION TO WEB. 2 Objectives In this chapter, you will: Become familiar with the architecture of the World Wide Web Learn about communication.
Web Database Programming Using PHP
ASP.NET Programming with C# and SQL Server First Edition
Chapter 33 - Active Server Pages (ASP)
Web Database Programming Using PHP
Chapter 19 PHP Part III Credits: Parts of the slides are based on slides created by textbook authors, P.J. Deitel and H. M. Deitel by Prentice Hall ©
Chapter 23 – ASP.NET Outline 23.1 Introduction NET Overview
The Request & Response object
Computer Science Department
Chapter 25 - Active Server Pages (ASP)
Web DB Programming: PHP
Presentation transcript:

 2004 Prentice Hall, Inc. All rights reserved. 1 Chapter 33 - Active Server Pages (ASP) Outline 33.1 Introduction 33.2 How Active Server Pages Work 33.3 Setup 33.4 Active Server Page Objects 33.5 Simple ASP Examples 33.6 File System Objects 33.7 Session Tracking and Cookies 33.8ActiveX Data Objects (ADO) 33.9 Accessing a Database from an Active Server Page Server-Side ActiveX Components Web Resources

 2004 Prentice Hall, Inc. All rights reserved. 2 Objectives In this tutorial, you will learn: –To program Active Server Pages using VBScript. –To understand how Active Server Pages work. –To understand the differences between client-side scripting and server-side scripting. –To be able to pass data between Web pages. –To be able to use server-side include statements. –To be able to use server-side ActiveX components. –To be able to create sessions. –To be able to use cookies. –To be able to use ActiveX Data Objects (ADO) to access a database.

 2004 Prentice Hall, Inc. All rights reserved Introduction Server-side technologies –Dynamically creates Web pages Use client information, server information and information from the Internet –Active Server Pages (ASP) Microsoft Server-side technology Dynamically build documents in response to client requests –Deliver dynamic Web content XHTML, DHTML, ActiveX controls, client-side scripts and Java applets

 2004 Prentice Hall, Inc. All rights reserved How Active Server Pages Work Active Server Pages –Processed by scripting engine Server-side ActiveX control –.asp file extension –Can contain XHTML tags –Scripting written with VBScript JavaScript also used Others (Independent Software Vendors) –Communication with Server Client HTTP request to server Active server page processes request and returns results

 2004 Prentice Hall, Inc. All rights reserved How Active Server Pages Work Active Server Pages,cont. –Communication with Server, cont. ASP document is loaded into memory –asp.dll scripting engine on server Parses (top to bottom)

 2004 Prentice Hall, Inc. All rights reserved Setup Web Server –Need to run Web server to use Active Server Pages IIS 5.0 (Internet Information Services) or higher –Create a virtual directory Copy files to c:\InetPub\Wwwroot

 2004 Prentice Hall, Inc. All rights reserved Active Server Page Objects Built-in objects –Communicate with a Web browser –Gather data sent by HTTP request –Distinguish between users –Request Get or post information Data provided by the user in an XHTML form Access to information stored on client machine –Cookies –File upload (binary) –Response Sends information to client –XHTML, text –Server Access to server methods or properties

 2004 Prentice Hall, Inc. All rights reserved Active Server Page Objects

 2004 Prentice Hall, Inc. All rights reserved Simple ASP Examples ASP Scripts –Scripting directive –Option Explicit As in VBScript, forces all variables to be declared in advance –FormatDateTime Time to display –Now Format to display in

 2004 Prentice Hall, Inc. All rights reserved. Outline 10 clock.asp (1 of 2) Scripting delimiter wraps around code executed on the server. Processing directive specifying scripting language Requires programmer explicitly define all variables

 2004 Prentice Hall, Inc. All rights reserved. Outline 11 clock.asp (2 of 2) Returns server date and time ( Now ) as a string formatted in vbLongDate format “ <%= “ is short for Response.write Statement is short for:

 2004 Prentice Hall, Inc. All rights reserved Simple ASP Examples Fig Simple Active Server Page.

 2004 Prentice Hall, Inc. All rights reserved. Outline 13 HTML generated by clock.asp (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline 14 HTML generated by clock.asp (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved Simple ASP Examples ASP processes input –Form information sent by client –E-commerce Web site Use to verify customer information –Server responds to process request –Form Using post method action attribute indicates the.asp file to which the form information is posted –Request object retrieves form data

 2004 Prentice Hall, Inc. All rights reserved. Outline 16 name.html (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline 17 action set to ASP file where information is post ed. name.html (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved Simple ASP Examples Fig XHTML document that requests an ASP.

 2004 Prentice Hall, Inc. All rights reserved. Outline 19 name.asp (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline 20 name.asp (2 of 2) Request object retrieves form data from text field “ namebox ”

 2004 Prentice Hall, Inc. All rights reserved Simple ASP Examples Fig ASP document that responds to a client request.

 2004 Prentice Hall, Inc. All rights reserved File System Objects File System Objects (FSOs) –Allow programmer to manipulate files, directories and drives –Read and write text –Microsoft Scripting Runtime Library (Fig 33.6) FileSystemObject, File, Folder, Drive and TextStream –Use to create directories, move files, determine whether a Drive exists FileSystemObject methods (Fig. 33.7) –File object Allows programmer to gather info about files, manipulate files, open files File properties and methods (Fig. 33.8)

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects File System Objects (FSOs) –Path property Contains File path in long name format –ShortName property Contains File path in short name format –Folder object Allows programmer to manipulate and gather info about directories Folder properties (Fig. 33.9)

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects File System Objects (FSOs) –IsRootFolder property Indicates whether folder is the root folder for the Drive If not: –Method ParentFolder Retrieves parent folder –Method Size Returns the total bytes the folder contains (includes subfolders)

 2004 Prentice Hall, Inc. All rights reserved File System Objects File System Objects (FSOs) –Drive object (Fig ) Gather information about drives Property DriveLetter –Contains drive letter Property SerialNumber –Contains drive serial number Property FreeSpace –Contains number of available bytes

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects File System Objects (FSOs) –TextStream object (Fig ) Manipulate text files

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved File System Objects Creating a guestbook –XHTML Form –hidden field Determine if page loaded by form submission –Write data to text file ServerVariables APPL_PHYSICAL_PATH OpenTextFile Append mode –8

 2004 Prentice Hall, Inc. All rights reserved File System Objects Creating a guestbook, cont. –Name returned as mailto: URL Request object –Chr function Generate characters from ASCII code –Always Close files

 2004 Prentice Hall, Inc. All rights reserved. Outline 38 guestbook.asp (1 of 5)

 2004 Prentice Hall, Inc. All rights reserved. Outline 39 guestbook.asp (2 of 5) Concatenated with file name guestbook.txt Creating a FSO instance assigned to reference fileObject Set is required to establish a variable in VBScript Request object retrieves hiddenInput value and tests it against string “ true ” Prints string followed by users name input in the form Date() assigns current server date to beginning of mailtoUrl Displays a mailto : link. Submitted name and are combined and assigned to string mailtoUrl Pass value 34 into VBScript Chr function to produce double quotes ( “” ) Request retrieves “ ” and “ username ” Pass Request method ServerVariables server key APPL_PHYSICAL_PATH

 2004 Prentice Hall, Inc. All rights reserved. Outline 40 guestbook.asp (3 of 5) Method OpenTextFile retrieves TextStream object for accessing file guestbook.txt Contstant 8 indicates append mode (writing to the end of the file.) TextStream method WriteLine writes to guestbook.txt Close() method closes the file Form post action to.asp page

 2004 Prentice Hall, Inc. All rights reserved. Outline 41 guestbook.asp (4 of 5) Form contains two text fields and text area for user input Passes parameter hiddenInput value “ true ”

 2004 Prentice Hall, Inc. All rights reserved. Outline 42 guestbook.asp (5 of 5) FSO object FileExists checks if guestbook.txt exists. Read entries from guestbook.txt and write XHTML to the client TextStream and ReadAll methods read entire contents of guestbook.txt Response.Write writes text to client. Contains XHTML markup rendered on client browser.

 2004 Prentice Hall, Inc. All rights reserved File System Objects Fig Guestbook Active Server Page.

 2004 Prentice Hall, Inc. All rights reserved File System Objects Fig Guestbook Active Server Page.

 2004 Prentice Hall, Inc. All rights reserved. Outline 45 XHTML generated by guestbook.asp (1 of 1)

 2004 Prentice Hall, Inc. All rights reserved File System Objects

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Session Tracking and Cookies –Helps server to distinguish between clients –Provide custom content Shopping cart Marketing/advertising –SessionID Assigned by server to each unique session Compared with sessionID s stored in server –Session object Timeout property –Length of session before it expires Abandon property –Terminates individual session

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies ASP application –Multiple ASP pages linked with session variables –Example instantpage.asp –Form, requests information from the user –Posted to process.asp process.asp –Redirects user to instantpage.asp if errors exist –Otherwise creates users ASP page –Stores message in session variable welcomeBack Every time user submits the form

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Server-side include –Commands embedded in XHTML documents –Add dynamic content –Places a.shtml include file within another file –Physical or virtual path –Not all Web servers support Written as comment –Performed before scripting code is interpreted. ASP page cannot determine which includes to use –Can contain scripting code Must use tag or delimiters

 2004 Prentice Hall, Inc. All rights reserved. Outline 50 instantpage.asp (1 of 4)

 2004 Prentice Hall, Inc. All rights reserved. Outline 51 instantpage.asp (2 of 4) Server-side include errorMessage session variable used for error messages welcomeBack session variable displays “welcome back” message to returning users If statement tests errorMessage equality to “ no error ”. Return True or False. If true, errorMessage value is written to client Else, WelcomeBack value is written to the client First time page is executed, line 35 returns true errorMessage never has a value unless errors are encountered Session object retrieves variable value Requests process.asp when form is posted

 2004 Prentice Hall, Inc. All rights reserved. Outline 52 instantpage.asp (3 of 4)

 2004 Prentice Hall, Inc. All rights reserved. Outline 53 instantpage.asp (4 of 4) Server-side include

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Fig ASP that posts user information to process.asp.

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Fig ASP that posts user information to process.asp.

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Fig ASP that posts user information to process.asp.

 2004 Prentice Hall, Inc. All rights reserved. Outline 57 header.shtml (1 of 1)

 2004 Prentice Hall, Inc. All rights reserved. Outline 58 footer.shtml server-side include file for the document footer

 2004 Prentice Hall, Inc. All rights reserved. Outline 59 process.asp (1 of 6) If statement validates contents of text field. If field is empty or contains default string yourfilename, lines assign XHTML error message to variable message. Assign message value to session variable errorMessage Server method Transfer requests instantpage.asp

 2004 Prentice Hall, Inc. All rights reserved. Outline 60 process.asp (2 of 6) FSO object is created if valid user name is entered and assigned reference fileObject Specify server path where ASP file is written Request.ServerVariables retrieves physical path Builds fileName by concatenating “ filename ” to the.asp file extension filePath passed FileExists method. Determines if file exists. If file exists, variable errorMessage value is set to XHTML containing error message Server.Transfer method requests instantpage.asp

 2004 Prentice Hall, Inc. All rights reserved. Outline 61 process.asp (3 of 6) Assigns XHTML for “welcome back” message to welcomeBack session variable Assign ASP scripting delimiters to string variables openMark and closeMark Construct XHTML for header

 2004 Prentice Hall, Inc. All rights reserved. Outline 62 process.asp (4 of 6) Form values retrieved using Request object footer variable assigned to XHTML footer contents

 2004 Prentice Hall, Inc. All rights reserved. Outline 63 process.asp (5 of 6) Lines send XHTML to client that contains link to created page

 2004 Prentice Hall, Inc. All rights reserved. Outline 64 process.asp (6 of 6)

 2004 Prentice Hall, Inc. All rights reserved. Outline 65 aboutme.asp (1 of 2)

 2004 Prentice Hall, Inc. All rights reserved. Outline 66 aboutme.asp (2 of 2)

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Fig Welcome back message displayed by instantpage.asp.

 2004 Prentice Hall, Inc. All rights reserved Session Tracking and Cookies Fig Error message generated by instantpage.asp.

 2004 Prentice Hall, Inc. All rights reserved ActiveX Data Objects (ADO) ADO –Enables database connectivity –Part of Universal Data Access architecture OLE DB provides low-level access ODBC allows C programs to access databases ADO allows web applications to access databases –Provides pre-built objects for use in ASP and VBScript Collections

 2004 Prentice Hall, Inc. All rights reserved ActiveX Data Objects (ADO) ADO OLE DB Legacy dataRelational data sources Application or Browser Non-relational data sources ODBC Fig Microsoft’s UDA architecture.

 2004 Prentice Hall, Inc. All rights reserved ActiveX Data Objects (ADO) Fig Portion of the ADO object model. Field Parameter Fields Error Parameters RecordSet Errors Command Connection

 2004 Prentice Hall, Inc. All rights reserved ActiveX Data Objects (ADO)

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Web applications –Communicating with databases Use ActiveX Data Objects (ADO) –Provides uniform way for programs to connect with databases –Three-tier distributed applications User interface –Created with XHTML, DHTML or XML –Contains ActiveX controls, client-side scripts, Java applets –Communicate directly with business logic Business logic Database access May reside on separate computers

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Web applications, cont. –Three-tier distributed applications, cont. Web servers build middle tier –Provide business logic Manipulates databases Communicates with client Web browsers –ASP communications with databases Use SQL-based queries ADO handled specifics –Through OLE DB Databases provide data source for dynamic content Allows users who are not familiar with Web languages to create Web pages Restrict access –Password protection Query Access database

 2004 Prentice Hall, Inc. All rights reserved. Outline 75 database.asp (1 of 2) Ignores errors until end of script Declares session variable errorString Server method CreateObject creates ADODB.Connection Method Open opens database specified by ODBC System DSN ( login ) errorHandlerLog processes errors loginData reference is set to an ADODB.recordset object Open method is passed string containing SQL query and ADODB.Connection object When Open finishes executing, points to first record or EOF if no records were found Sets session variable loginData to variable loginData which references the ADODB.recordset containing all records matching SQL query errorHandlerLog called again

 2004 Prentice Hall, Inc. All rights reserved. Outline 76 database.asp (2 of 2) Err object Number property contains VBScript error number. Tests if error has occurred. If true, errorString variable is assigned XHTML text containing error number and message Error number and message concatenated to variable errorString

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Fig Error messages sent to login.asp by database.asp.

 2004 Prentice Hall, Inc. All rights reserved. Outline 78 login.asp (1 of 7) Assigns SQL query to session variable query Executes database.asp to retrieve login IDs from the database

 2004 Prentice Hall, Inc. All rights reserved. Outline 79 login.asp (2 of 7) Tests if session variable errorString value is empty string Lines test is session variable loginFailure is True

 2004 Prentice Hall, Inc. All rights reserved. Outline 80 login.asp (3 of 7) select structure builds drop- down list of loginID s Requests loginID cookieSelects the returning user’s login ID option Build loginID options

 2004 Prentice Hall, Inc. All rights reserved. Outline 81 login.asp (4 of 7) If false, print error message to user

 2004 Prentice Hall, Inc. All rights reserved. Outline 82 login.asp (5 of 7) Tests for EOF If statement tests whether option needs to be selected found set to False before loop

 2004 Prentice Hall, Inc. All rights reserved. Outline 83 login.asp (6 of 7) If statement writes selected for an option Once selected is written for an option, found set to true Determines whether current record’s loginID field is equal to loginID cookie

 2004 Prentice Hall, Inc. All rights reserved. Outline 84 login.asp (7 of 7) while loop (lines ) iterates through loginData ’s records Sets option value to current login ID Writes option display as current login ID Increments the record set pointer to next record

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Fig ASP document that allows the user to log in to a site.

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Fig ASP document that allows the user to log in to a site.

 2004 Prentice Hall, Inc. All rights reserved. Outline 87 submitlogin.asp (1 of 2) Check whether password field is empty or id loginID field contains default value WHERE specifies a condition on which records are selected Executes database.asp to query database Sets reference loginData to session variable loginData (contains records matching query.) Checks password against the password in recordset If so, variable loginFailure set to true, client redirected back to login.asp

 2004 Prentice Hall, Inc. All rights reserved. Outline 88 submitlogin.asp (2 of 2) If true, line writes form’s loginID value as cookie named loginID Sets session variable loginFailure value to False Sets cookie’s expiration date to current date plus 3 days Calls Server method Transfer to redirect client to instantpage.asp Otherwise loginFailure set to True and client is redirected to login.asp

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Fig ASP document that validates user login.

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Fig ASP document that validates user login.

 2004 Prentice Hall, Inc. All rights reserved Accessing a Database from an Active Server Page Fig Cookies folder before and after cookie creation.

 2004 Prentice Hall, Inc. All rights reserved Server-Side ActiveX Components ActiveX controls on the server with no GUI –Make features available in ASP –AdRotator ActiveX component Rotates advertisements on a Web page Randomly displays one of several advertisements Minimizes space on a Web page committed to advertisements Client does not have to support ActiveX technologies (on the server) –PageCounter ActiveX component Page “hit” counter

 2004 Prentice Hall, Inc. All rights reserved Server-Side ActiveX Components

 2004 Prentice Hall, Inc. All rights reserved. Outline 94 component.asp (1 of 4)

 2004 Prentice Hall, Inc. All rights reserved. Outline 95 component.asp (2 of 4) Creates AdRotator component instance, assigns it reference rotator Sends advertisement as HTML to client. Method GetAdvertisement called using reference rotator. Retrieves advertisements from config.txt Obtains information about user’s browser Check property VBScript value Test JavaScript property

 2004 Prentice Hall, Inc. All rights reserved. Outline 96 component.asp (3 of 4) BrowserType object’s Browser, Version and MinorVer properties can obtain similar client information Tests Cookies property to determine if browser supports cookies Increments number of “hits” by one Passes server variable key HTTP_USER_AGENT to ServerVariables, obtains string containing user information

 2004 Prentice Hall, Inc. All rights reserved. Outline 97 component.asp (4 of 4) Returns number of “hits”

 2004 Prentice Hall, Inc. All rights reserved Server-Side ActiveX Components Fig Demonstrating server-side ActiveX components.

 2004 Prentice Hall, Inc. All rights reserved Server-Side ActiveX Components Fig Demonstrating server-side ActiveX components.

 2004 Prentice Hall, Inc. All rights reserved Server-Side ActiveX Components Fig Demonstrating server-side ActiveX components.

 2004 Prentice Hall, Inc. All rights reserved. Outline 101 config.txt (1 of 1) Header contains REDIRECT file URL Asterisk separates header from advertisements Advertisement dimensionsImage URL, destination URL, alt value, image display ratio

 2004 Prentice Hall, Inc. All rights reserved. Outline 102 redirect.asp (1 of 1)