Active Server Pages Overview

Slides:



Advertisements
Similar presentations
WEB DESIGN TABLES, PAGE LAYOUT AND FORMS. Page Layout Page Layout is an important part of web design Why do you think your page layout is important?
Advertisements

JavaScript FaaDoOEngineers.com FaaDoOEngineers.com.
Using Macros and Visual Basic for Applications (VBA) with Excel
Microsoft Excel 2003 Illustrated Complete Excel Files and Incorporating Web Information Sharing.
CIS101 Introduction to Computing Week 08. Agenda Your questions JavaScript text Resume project HTML Project Six This week online Next class.
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.
B.Sc. Multimedia ComputingMedia Technologies Database Technologies.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
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.
4/8/99 C. Edward Chow Page 1 Active Server Page It is a server-side scripting environment for creating dynamic content. ASP are files with.asp extension,
4/8/99 C. Edward Chow Page 1 Internet Services Manager Click Start | Programs | Administrative Tools | Internet Services Manager.
ASP.NET Programming with C# and SQL Server First Edition Chapter 8 Manipulating SQL Server Databases with ASP.NET.
MIS2502: Data Analytics MySQL and SQL Workbench David Schuff
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
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 Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
8 Chapter Eight Server-side Scripts. 8 Chapter Objectives Create dynamic Web pages that retrieve and display database data using Active Server Pages Process.
4-Sep-15 HTML Forms Mrs. Goins Web Design Class. Parts of a Web Form A Form is an area that can contain Form Control/Elements. Each piece of information.
4-1 INTERNET DATABASE CONNECTOR Colorado Technical University IT420 Tim Peterson.
Chapter 7 PHP Interacts with Ms. Access (Open DataBase Connectivity (ODBC))
Basics of Web Databases With the advent of Web database technology, Web pages are no longer static, but dynamic with connection to a back-end database.
Data-Enabled Web Sites: Classibooks.com & Internet Database Technologies Colin Fukai April 4, 2000 Gonzaga University.
Active Server Pages (ASP) 1. 2 Introduction Active Server Pages (ASP) –Server-side text file –Processed in response to client request –Pages are processed.
Server Side Programming ASP1 Server Side Programming Database Integration (cont.) Internet Systems Design.
Creating a Web Site to Gather Data and Conduct Research.
Robinson_CIS_285_2005 HTML FORMS CIS 285 Winter_2005 Instructor: Mary Robinson.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
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.
Introduction to HTML. What is a HTML File?  HTML stands for Hyper Text Markup Language  An HTML file is a text file containing small markup tags  The.
Tutorial 10 by Sam ine1020 Introduction to Internet Engineering 1 Database & Server-side Scripting Tutorial 10.
ASP Introduction Y.-H. Chen International College Ming-Chuan University Fall, 2004.
Lecture Note 1: Getting Started With ASP.  Introduction to ASP  Introduction to ASP An ASP file can contain text, HTML tags and scripts. Scripts in.
Exploring Office Grauer and Barber 1 Committed to Shaping the Next Generation of IT Experts. Chapter 2 – Gaining Proficiency: The Web and Business.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
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.
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,
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
ASP. ASP is a powerful tool for making dynamic and interactive Web pages An ASP file can contain text, HTML tags and scripts. Scripts in an ASP file are.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
Windows 2000/ XP Overview Norman White Stern School of Business.
Using databases ActiveX Data Objects (ADO) Connecting to a database Reading data from a database Inserting, updating and deleting records Using databases.
MYSQL AND MYSQL WORKBENCH MIS2502 Data Analytics.
FORMS Explained By: Jasdeep Kaur. Lecturer, Department of Computer Application, PGG.C.G., Sector: 42, Chandigarh.
A S P. Outline  The introduction of ASP  Why we choose ASP  How ASP works  Basic syntax rule of ASP  ASP’S object model  Limitations of ASP  Summary.
ASP – Web Programming Class  Ravi Anand. ASP – Active Server Pages What is ASP? - Microsoft Technology - Can Run using IIS/PWS/Others - Helps us create.
Lecture 6 Sara Almudauh ASP.NET Part 1 Development of Internet Application 1501CT - Sara Almudauh.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Server Side Programming Database Integration
ASP.NET Programming with C# and SQL Server First Edition
Introduction to HTML.
Introduction to Dynamic Web Programming
ASP Explained By: Sarbjit Kaur.
Active Server Pages Computer Science 40S.
mysql and mysql workbench
Introduction to Programming the WWW I
Multi-host Internet Access Portal (MIAP) Enhancement Guide
Chapter 23 – ASP.NET Outline 23.1 Introduction NET Overview
ISC440: Web Programming 2 Server-side Scripting PHP 3
The Request & Response object
ASP.
Client side & Server side scripting
MIS2502: Data Analytics MySQL and SQL Workbench
Chapter 10 ADO.
Creating Forms on a Web Page
PHP an introduction.
Presentation transcript:

Active Server Pages Overview Introduction COM and ASP Database Access ASP Access to other Apps Favorite Sites to Visit 1/13/2019 Dr. Paul Bao, COMP035

Introduction Microsoft® Active Server Pages (ASP) is a server-side scripting technology used to create dynamic and interactive Web applications. An ASP page is an HTML page containing server-side scripts processed by the Web server Server-side scripts run when a browser requests an .asp file from the Web server. ASP is called by the Web server, which processes the requested file from top to bottom and executes any script commands. It then formats a standard Web page and sends it to the browser. 1/13/2019 Dr. Paul Bao, COMP035

Built-in Objects Request - to get information from the user Response - to send information to the user Server - to control the Internet Information Server Session - to store information about and change settings for the user's current Web-server session Application - to share application-level information and control settings for the lifetime of the application Others - more built-in objects have been introduced in IIS 4 1/13/2019 Dr. Paul Bao, COMP035

Request & Response Objects -<html> <head> <title>Who Are You?</title> </head><body> <p><%= formatdatetime((now),vblongdate) %></p> <p>Thank You For Filling Out the Form - <% Response.Write Request.Form("name") %></p> <p>You are <%= Request.Form("age") %> Years of Age</p> <p>Your shoe size is <%= Request.Form("size") %> <% If Request.Form("size") > 12 then Response.Write " You have big feet" End If %></p> <p>Your Bestest Color is: <%= Request.Form("color") %> </body> </html> 1/13/2019 Dr. Paul Bao, COMP035

Server Objects CreateObject() method creates an instance of a server component. Syntax Server.CreateObject( progID ) Parameters progID Specifies the type of object to create. The format for progID is [Vendor.]Component[.Version]. <% Set MyAd = Server.CreateObject("MSWC.AdRotator") %> 1/13/2019 Dr. Paul Bao, COMP035

Server Objects Compenents Ad Rotator - Automatically rotates advertisements displayed on a page according to a specified schedule. Browser Capabilities - Determines the capabilities, type, and version of each browser that accesses your Web site. Database Access - Provides access to databases. Content Linking - Creates tables of contents for Web pages, and links them together sequentially like pages in a book. File Access - Provides access to file input and output. PageCounter - Provide page counter 1/13/2019 Dr. Paul Bao, COMP035

Session Objects <% Session("username") = "Janine" You can use the Session object to store information needed for a particular user-session. Variables stored in the Session object are not discarded when the user jumps between pages in the application <% Session("username") = "Janine" Session("age") = 24%> <% Set Session("Obj1") = Server.CreateObject("MyComponent") %> You can then call the methods and properties of MyObj on subsequent Web pages, by using the following: <% Session("Obj1").MyObjMethod %> 1/13/2019 Dr. Paul Bao, COMP035

Server Compenent Example <% Set pageCount = Server.CreateObject("MSWC.PageCounter") %> <% pageCount.PageHit %> You are visitor number <% =pageCount.Hits %> to this Web site. 1/13/2019 Dr. Paul Bao, COMP035

Application Objects You can store values in the Application object. Information stored in the Application object is available throughout the application and has application scope. <% Application("greeting") = "Welcome to My Web World!" Application("num") = 25%> <% Set Application("Obj1") = Server.CreateObject("MyComponent") %> You can then reference the methods and properties of MyObj on subsequent Web pages, by using the following: <% Application("Obj1").MyObjMethod %> 1/13/2019 Dr. Paul Bao, COMP035

COM Objects It is possible to extend your ASP scripts using COM components COM extends your scripting capabilities by providing a compact, reusable, and secure means of gaining access to information. You can call components from any script or programming language that supports Automation. 1/13/2019 Dr. Paul Bao, COMP035

How to Use ASP Write and Run an ASP Page. Describes how to use Visual Basic® Scripting Edition (VBScript) and HTML tags. Send Information Using Forms. Shows how to display forms on an HTML page. Create a Guest Book. Uses forms to gather information from visitors, store the information in a database, and display the database contents in a Web page. Display an Excel Spreadsheet in ASP. Explains how to display an Excel spreadsheet in a Web page. 1/13/2019 Dr. Paul Bao, COMP035

Write and Run an ASP Page VBScript syntax and coding samples To create an ASP page, use a text editor to insert script commands into an HTML page. Saving the page with an .asp file name extension. To view the results of a script, request the page using a Web browser. VBScript is the default scripting language for ASP 1/13/2019 Dr. Paul Bao, COMP035

Example I <%@ Language=VBScript %> <html> <head> <title>Example 1</title> </head> <body> <%FirstVar = "Hello world!" %> <%=FirstVar%> </body> </html> 1/13/2019 Dr. Paul Bao, COMP035

Example I Assigns the text "Hello World" to the variable FirstVar. Uses HTML to make an HTML page. Uses <%FirstVar%> to print out the value of the variable FirstVar. Ends the HTML page. 1/13/2019 Dr. Paul Bao, COMP035

Example 2 This example incorporates a FOR loop in the ASP page. <%@ Language=VBScript %> <html><head> <title>Example 2</title> </head> <body> <%FirstVar = "Hello world!"%> <%FOR i=1 TO 10%> <%=FirstVar%> <%NEXT%> </body></html> 1/13/2019 Dr. Paul Bao, COMP035

Example 3 In this example, a time stamp is added to the ASP page. The word time is a predefined VBScript function variable containing the current time. There are more than 90 functions in VBScript. 1/13/2019 Dr. Paul Bao, COMP035

Example 3 <%@ Language=VBScript %> <html><head> <title>Example 3</title> </head> <body> <%FirstVar = "Hello world!"%> The time is: <%=time%> <BR> <%FOR i=1 TO 10%> <%=FirstVar%> <%NEXT%> </body> </html> 1/13/2019 Dr. Paul Bao, COMP035

Example 4 (If statement) <%@ Language=VBScript %> <html><head> <title>Example 4</title> </head> <body> <%IF Hour(time)>18 OR Hour(time)<4 THEN%> Good Night Everyone. <%ELSE%> Good Morning Everyone. <%END IF%> </body> </html> 1/13/2019 Dr. Paul Bao, COMP035

Send Information by Using Forms With ASP, you can embed scripts written in VBScript directly into an HTML file to process the form. ASP processes the script commands and returns the results to the browser. Create an HTML page that displays various elements of an HTML form. 1/13/2019 Dr. Paul Bao, COMP035

Input.html <html><head> <title>Who Are You?</title> </head><body> <p>Please tell us who you are</p> <form action="form.asp" method="post"> <p>Your Name : <input type="text" name="name"> </p> <p>Your Ages : <input type="text" name="age"></p> <p>Shoe Size : <input type="text" name="size"></p> <p>Your Bestest Color : <select name="color" SIZE=3> <option selected> Red <option> Blue <option> Green </select></p> <p><input type="submit"></p> </form></body></html> 1/13/2019 Dr. Paul Bao, COMP035

Form.asp <html><head> <title>Who Are You?</title> </head> <body> <p>Thank You For Filling Out the Form - <% Response.Write Request.Form("name") %></p> <p>You are <%= Request.Form("age") %> Years of Age</p> <p>Your shoe size is <%= Request.Form("size") %> <%If Request.Form("size") > 12 then Response.Write " You have big feet" End If %></p> <p>Your Bestest Color is: <%= Request.Form("color") %> </body> </html> 1/13/2019 Dr. Paul Bao, COMP035

Create a Guest Book How to develop a guest book application. Guest books allow visitors to your site a chance to give you feedback. Information such as the visitor’s name, e-mail address, and comments can be available to you. 1/13/2019 Dr. Paul Bao, COMP035

Creating the Guest Book Database You must first create an Access database called Guestbook.mdb. The database must have the fields with the properties described in the following table. 1/13/2019 Dr. Paul Bao, COMP035

Create DSN Create a data source name (DSN) connection to the database so your ASP application can interact with it. How to create a DSN on Windows NT and Windows 2000 In the ODBC Data Source Administrator, select the ODBC icon. Select File DSN. Select Add, select Microsoft Access Driver, and click Next. Type in a descriptive name for your file DSN (Guestbook) and click Next. Click Finish, click Select, specify the location of the database file, and select OK. Click OK twice. After you specify the location of the database file, the ODBC Data Source Administrator creates a file DSN for it. 1/13/2019 Dr. Paul Bao, COMP035

Coonection to Database File DSN-less set objConn = server.createobject("ADODB.Connection") 'Opens the connection to the data store mdbfile=Server.MapPath("Guestbook.mdb") objConn.Open "Driver={Microsoft Access Driver (*.mdb)}; DBQ=" & mdbfile & ";” DSN strProvider="DSN=guestbook.dsn;" objConn.Open strProvider 1/13/2019 Dr. Paul Bao, COMP035

Guestbook.asp Demo Guestbook.asp 1/13/2019 Dr. Paul Bao, COMP035

View Database in a Browser Demo viewdb.asp 1/13/2019 Dr. Paul Bao, COMP035

Display an Excel Spreadsheet in ASP Display a Microsoft Excel spreadsheet in a Web page. Use ActiveX® Data Objects (ADO) component, which is used as a connection mechanism to provide access to data. How to view and edit a spreadsheet with a Web browser using ADO 1/13/2019 Dr. Paul Bao, COMP035

Prepare Excel spreadsheet Create a spreadsheet as ASPTOC.xls in the your NT directory. Highlight the rows and columns on the spreadsheet that you want displayed in the Web page. On the Insert menu, choose Name, and select Define. If there are any names listed, select them and select Delete. Type a name for the workbook, select Add, and select OK. To display the spreadsheet in a Web page, you must create a DSN for the spreadsheet Demo asptol.asp 1/13/2019 Dr. Paul Bao, COMP035

Redirect Users from Ad Links When a user clicks the ad, the browser appends a query string to the request to the server. Then, the server directs the user’s browser to the ad’s URL. Adrotatorredirect.asp: <%@Language=VBScript %> <html><head> <title>Redirection Page</title> </head> <body> <%'Set the response buffer on Response.Buffer = True Dim lsURL 'Obtain the URL from the query string lsURL = Request.QueryString("URL") 'Clear the response and redirect to URL Response.Clear() Response.Redirect(lsURL)%> </body></html> 1/13/2019 Dr. Paul Bao, COMP035

Count Page Hits The Page Counter component uses an internal object to record page hit-count totals for all pages on the server. At regular intervals, this object saves all information to a text file so that no counts are lost due to power loss or system failure. The Page Counter component uses the following three methods: Hits(). This displays the number of hits for a Web page. The default is the current page. PageHit(). This increments the hit count for the current page. Reset(). This resets the hit count for a page to zero. The default is the current page. 1/13/2019 Dr. Paul Bao, COMP035

Pagehit.asp <% Set pageCount = Server.CreateObject("MSWC.PageCounter") %> <% pageCount.PageHit %> You are visitor number <% =pageCount.Hits %> to this Web site. 1/13/2019 Dr. Paul Bao, COMP035

Remote Server Scripting Have you ever wanted to write an ASP page that did the following: execute an ASP script on another webserver retrieve that remote ASP script's output act on that output? Or perhaps you've always wanted to be able to do remote Server Side Includes, like <!--#include file="http://www.someserver.com/somefile.txt"-->. ASP, alone, can't do that sort of thing. There is a free component, AspTear, from Softwing 1/13/2019 Dr. Paul Bao, COMP035

Remote Stock Quote Let's say that you want to execute an ASP script on another server that returns the current stock price for Microsoft. We could write our own ASP script on our own server that would show this value 1/13/2019 Dr. Paul Bao, COMP035

Stock.asp 'AspTear constants Const Request_POST = 1 Const Request_GET = 2 Set objTear = CreateObject("SOFTWING.ASPtear") Response.ContentType = "text/html" On Error Resume Next Dim strRetval ' URL, action, payload, username, password strRetval = objTear.Retrieve("http://www.stockquotes.com/msft.asp", Request_GET, "", "", "") If Err.Number <> 0 Then Response.Write "<b>" If Err.Number >= 400 Then Response.Write "Server returned error: " & Err.Number Else Response.Write "Component/WinInet error: " & Err.Description End If Response.Write "</b>" Response.End End If Response.Write "Microsoft currently selling at " & FormatCurrency(strRetval, 2) 1/13/2019 Dr. Paul Bao, COMP035

Remote Quote of Any Stock let's say that there was an ASP page that would return any stock quote. All you needed to do was specify the stock symbol in the QueryString. Let's look at how the code for that might look: 1/13/2019 Dr. Paul Bao, COMP035

AnyStock.asp 'AspTear constants Const Request_POST = 1 Const Request_GET = 2 Set objTear = CreateObject("SOFTWING.ASPtear") Response.ContentType = "text/html" On Error Resume Next Dim strRetval ' URL, action, payload, username, password strRetval = objTear.Retrieve("http://www.stockquotes.com/getquote.asp", Request_GET, "symbol=MSFT", "", "") ' ... Error checking code omitted ... Response.Write "Microsoft currently selling at " & FormatCurrency(strRetval, 2) 1/13/2019 Dr. Paul Bao, COMP035

Favorite Links to Visit Http://www.microsoft.com 1/13/2019 Dr. Paul Bao, COMP035