Rutgers - Active Server PagesPresentation Transcript
Active Server Pages: Web Scripting Made Easy A Hands-On Workshop in the New Brunswick Computing Services Instructional Lab By Michael Dobe Sponsored by The New Jersey Intercampus Network Internet Technology Project http://www.njin.net
Fast paced five-part workshop designed to prepare you to create a truly dynamic site using Active Server Pages, VBScript, and Microsoft's IIS 4.0 Server on the Internet or on a college/university intranet.
By the End of the Workshop You Will:
Understand the concepts and components of Active Server Pages
Know the steps to set up and configure development and production ASP Server environments
Learn the basics of ASP Scripting With VBScript
Manage states and events with application and session objects
Understand and use the bundled Active Server components
Connect to a MS Access database and display information
Know the steps to create your own ASP components
Active Server Pages Workshop: About Your Instructor
6 Years Experience With Web Technologies in Higher Ed and Industry
Designed and Implemented
Clio Web Project For Internet Web Hosting at Rutgers
Corporate Intranets for BMG Direct Marketing and Warburg Dillon Read, LLC
Currently Working As Web Architect for Modem Media.Poppe Tyson.
See the Instructor’s Home Page at http://clioweb.net/mdobe
FOR MORE INFO...
About You and Your Classmates
Who Are Your Classmates?
What Do Your Classmates Do With Computers?
What Motivated You to Take This Course?
What Do You Hope to Get Out of This Workshop?
“ Active Server Pages” Administrative Information
Course Slides in Hard Copy and on the Web
Prerequisites: Experience With HTML and Web Server Technologies; some scripting experience desirable
Reference Book, Beginning Active Server Pages 2.0 , is available from “brick and mortar” and online retailers
Workshop runs from 9:30-4:00 PM
See the NJIN Web Site at http://www.njin.net
FOR MORE INFO ...
Demos and Hands-on Exercises: About The Systems
Will Use an NT Server (clio.rutgers.edu) and Workstations in the Classroom For this Workshop
Web Server Demos Using VNC (Virtual Network Computing)
Will Make Use of Web Browsers, MS-FrontPage 2000, MS Office 2000 and Visual InterDev 6.0
Workstation Configurations Will Allow You To Create and Modify FrontPage 2000 Webs on the Web Server and to Author ASP Pages
http://www. njin .net
A Note on Remote NT Systems Management
Free Option: Virtual Network Computing
Available from http://www.uk.research.att.com/vnc/
Using VNC, You Can Manage NT Server From a PC Workstation
Active Server Pages: Part I Topics: “Review of Client and Server-Side Scripting”; “Getting Up and Running”; “Introducing ASP and VBScript ”
Part I Goals
Discuss client side/server side scripting
Introduce Active Server Pages (ASP)
Explain what platforms these scripts run on and which browsers can see the results
Discuss configuration of development and production ASP environments
Discuss the structure of an ASP page
Introduce VBScript, the default scripting language for ASP
“ Active Server Pages” 5 Parts at a Glance
Part 1: Introduction
Part 2: ASP Scripting in VBScript, Pt. I
Part 3: ASP Scripting in VBScript, Pt. II
Part 4: ASP Components
Part 5: ADO Components
Client-Side and Server-Side Scripting: Your Web Development Options?
Code Must Reside on a Server
Code Can Be Executed
On a Server (Server-Side Scripts)
In a Client Browser (Client-Side Scripts)
Client-Side Scripting Limitations?
Reality: May Run a Mix of Code, Some Intended For Client and Other For Server-Side Execution
Benefits of Server-Side Scripting: Some Basic Things to Consider
Why Use Server-Side Scripts?
Protection of Your Source Code:
People Can’t See the Source Code, Only the HTML the Server Returns to the Browser
Independence From Browser Specificity: Server-Side Scripts Work With Any Browser!
Benefits of Server-Side Scripting: Some Basic Things to Consider
Why Use Active Server Pages Instead of CGI? Ease of Use? Speed?
ASP Default Server-Side Scripting on IIS, But CGI (and even Perl) work on NT ...
“ Active Server Pages is an open, compile-free application environment in which you can combine HTML, scripts, and reusable ActiveX server components to create dynamic and powerful Web-based business solutions. Active Server Pages enables server side scripting for IIS with native support for both VBScript and Jscript.”
- Nancy Winnick Cluts (MSDN Web Workshop)
ASP and The CGI Model
ASP = Active Server Pages
Another Form of Server-Side Scripting
Like CGI, Can Be Used With Any Browser
Also Like CGI, Users See the HTML Code and Not the Script Itself
Unlike CGI, It Is Tied to the Microsoft Platform ... Well, sort of ...
Benefits of Using Active Server Pages
Customize Content on Per-Browser Basis
Tight Integration With OS
Run as Service in NT
Tie-in To MS ACLs (Access Control Lists)
Support For ActiveX Server Components (Sever-Side Execution Eliminates Browser-Specificity)
What You Need to Make ASP Work
ASP Supported By Default in IIS 4.0
Use NT Server With Internet Information Server 4.0 For Production Web Environment
For Development You Can Use Personal Web Server for Win 95/98 and Peer Web Services for NT Workstation 4.0 (Both Called PWS)
Need PWS Version 4 For ASP!
PWS Version Included With FP 98 Does Not Support ASP!!!!!
Steps to Enabling ASP Support
IIS 4 and PWS 4 Support ASP By Default
Both Available for Free as Part of NT Server 4 Option Pack
IIS Documentation Installs With Option Pack:
Chili!Soft Offers Extensions For Other Non-MS Operating Systems and Web Servers
Available for Apache, Lotus, Netscape and O'Reilly, running on Windows NT, Sun Solaris and IBM AIX
Using ASP With IIS 4: A Review of MMC and ISM
URLs and IIS Directory Structure
Internet Guest Account
Web Publishing Service
Internet Service Manager:
URLs and File Structure of IIS
The Internet Guest Account
Installation Will Create the Internet Guest Account, Which is there to Allow Anonymous Access to Browse Your Site
The Internet Guest Account is called IUSER_computername (computername is your server’s NetBIOS name)
The Web Application Manager user account is IWAM_computername
Microsoft Management Console (MMC) and the NT Service Manager
MMC Is an Interface to the NT Service: “Web Publishing Services”
Used to Manage the Hypertext Transfer Protocol Server (IIS) and Other TCP/IP Services
DEMONSTRATION OF ISM
GUI Tool: MMC
Using ASP With PWS 4: The Administrative Interface
Review of Virtual Directories
Permissions: Read, Execute, Scripts
Virtual Directory Mapping Implementations on PWS 4 and IIS 4
Creating Your Project Virtual Directory
Ready For Your First Server-Side Script in ASP?
Virtual Servers vs. Virtual Directories
Virtual Servers Are Separate Hostnames On the Same Physical Machine Bound to Different NICs (or Bound to Same NIC) Virtual Servers Have Their Own Separate Configs. Virtual Servers Appear to the Outside World as Separate Machines.
Virtual Directories Are Directories Which Appear Below the Root Directory in a Web Browser. May Be Located on the Same Physical Machine or on Another Machine. Virtual Directories Appear to the Outside World as Part of the Same Server.
Why Would You Use a Virtual Server or a Virtual Directory?
Perhaps you would use a Virtual Directory for Active Server Pages?
Languages Used for ASP?
What Are ASP Pages Written In?
PerlScript (ActiveState Tool Corp.)
ASP can integrate Java and ActiveX Technologies. Usually the Latter.
Most Common Language: VBScript Defined
“ Microsoft® Visual Basic® Scripting Edition, a subset of the Microsoft® Visual Basic® programming language, is a fast, portable, lightweight interpreter for use in World Wide Web browsers and other applications that use Microsoft® ActiveX® Controls, Automation servers, and Java applets.”
- Microsoft Script Technologies Site
Ways to Write ASP Code: Your Choice of Editors
Any Test Editor: Notepad, vi (MKS Toolkit)
FrontPage 98 or 2000
98 Sometimes Alters Code
Workaround is Available
2000 Support is More Robust
Visual InterDev 6.0
Part of Visual Studio
Group Development Tool
Using FrontPage 98
This Course Will Use FP98 as Editor
To Prevent FP 98 From Changing Code:
Using the FrontPage Editor Menu,
Select Insert | FrontPageComponent | InsertHTML
option to place
<!--webbot bot="HTMLMarkup" startspan --> and <!--webbot bot="HTMLMarkup" endspan -->
tags around your ASP code, so that is not modified by FrontPage.
Structure of an ASP Page
ASP Script Code Mixed in Page With Regular HTML Code
2 Ways to Denote ASP Scripts
<% Here is a Script %>
<SCRIPT LANGUAGE=VBSCRIPT RUNAT=SERVER>
We Will Use the Former Convention
<HTML> <HEAD> <TITLE>Polite Web Server</TITLE> </HEAD> <BODY BGCOLOR="wheat"> <P> <FONT COLOR="Teal" SIZE="3"><B> The Polite Web Server, at <%= Time %> on <%= Date %> </B></FONT></P> <P><B> <% If Hour(Now) < 8 Then %> Don't you know what time it is? I was still in bed! <% Else Randomize intChoice = Int(Rnd * 4) Select Case intChoice Case 0 %> So, where do you want me to go today? <% Case 1 %> Well, look whose back visiting us again... <% Case 2 %> Hi there, and welcome to our site. <% Case 3 %> It's raining here, what's the weather at your end like? <% End Select End If %> </B></P> <HR> </BODY> </HTML>
In-Class Demo of Simple Script
The Simple “Punctual Web Server” Program (Example From Wrox.com)
Write Program in FP 2000
Run Code on a Workstation Using Personal Web Server
Test and Troubleshoot
Active Server Pages: Part II Topics: “HTML Forms” and “VBScript Basics: Variables, Variants, Operators, String Manipulation and Arrays”
Goals For Part II
Review Use of Forms
Introduce ASP Basics: HTML Forms and Variables With VBScript
Download and Install Sample Code From Wrox.com
Work on Forms-based Examples
VBScript Variables in Depth
Strings and Arrays
Work on String Manipulation and Array Examples
Review of HTML Forms
Pieces of the HTML Form (YourColor.html)
<FORM ACTION=“colors.asp" METHOD=post>
<P>Please Type Your Favorite Color Here:</P>
<P><INPUT NAME="MyFavoriteColor" ></P>
<INPUT TYPE="submit" VALUE="Submit This Form">
<P><INPUT TYPE="reset" VALUE="Reset This Form"></P>
Using Forms in FP 2000
By Default FrontPage 2000 Wants To Send Output To a Text File on the Server
Inserting Form Elements in the “Normal View” Inserts a FrontPage Bot, a.k.a. “FrontPage Component”
Best to Hand Code the HTML for the Forms in the “HTML View”
Using ASP Pages to Process User Input From HTML Forms
Sent Your Form Data to colors.asp, So Now We Need a file called colors.asp …
We gathered the Following Information From the User: MyFavoriteColor
We Need a Way to Do Something With MyFavoriteColor -- Enter VBScript Variables
What are Variables?
“ A variable is a section of memory that is allocated a name by the programmer. These sections of memory can be used to store pieces of information that will be used in the program. Think of variables as you might think of boxes. They're simply containers for information that you wish to store.”
Used anytime you need to make a choice among several answers (more than just True and False) then use Select Case .
The syntax for Select Case has four parts: State which variable to test; State a possible answer and what to do if that answer is correct; Repeat for as many possible answers as you want to handle; End the Select Case control structure
Flow Control Walkthrough 2: TioSelectOneForm.asp
<TITLE>Spring Retreat Form</TITLE>
<H1>Corporate Retreat Registration</H1>
<H3>To get the logistics information
for your meeting please answer these two questions.</H3>