Presentation is loading. Please wait.

Presentation is loading. Please wait.

Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 

Similar presentations


Presentation on theme: "Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular "— Presentation transcript:

1

2 Active Server Pages

3  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular  What first-generation Internet/intranet applications brought to the browser/server relationship  Why Active Server Pages were created

4  In this chapter, you will learn:  The role of scripting languages  How a Web application works  The role of the Web server  How to create and test a simple Active Server Page application

5  The relationship between your browser and a distant server was pretty simple  You requested a Web page via your browser, the server received your request, and the server sent back the page that you wanted  Through experience, we learned that the third part of the URL is the folder path, and that it indicates the precise folder on the Web server in which the Web resource is stored

6  The last part of the URL, specifies the Web resource we requested  As we cruised around, we became very familiar with the following types of resources: ◦ Hypertext Markup Language (HTML) documents ◦ Graphics

7  One of the changes that evolved was the first- generation Internet/intranet application  It was an extension to Web servers and was called Common Gateway Interface (CGI)  CGI allowed Web sites to dynamically create Web pages from a program typically written in C or a scripting language such as Perl

8  CGI added functionality to the Web  CGI programs often exhausted memory space on Windows computers  These shortcomings eventually led to Active Server Pages, or ASP

9  Active Server Pages (ASP) generate HTML and pass the dynamically created HTML to the browser to be displayed to the user  ASP applications run in a thread, which is the smallest unit of execution of a process  ASP provides a better solution for Web applications in Windows environments than CGI  ASP applications run three to five times faster than their CGI counterparts and can incorporate HTML pages and forms, scripts written in VBscript or JavaScript, and ActiveX components

10  As Web users became more experienced with ASP, they began running into elements such as the following: ◦ Java Applets ◦ ActiveX controls ◦ Extensible Markup Language (XML) documents

11  Active Server Pages create their value through the scripts that they contain  Scripts, or scripting, are lines of code that accomplish a specific task, such as retrieving data from a file  You can mix HTML tags and scripts in an ASP by using a special … tag  There are two kinds of scripting, client-side and server-side

12  Client-side scripts download to and execute on the client  Server-side scripts run directly on the server and generate data to be viewed by the browser in HTML format  Most Web users have encountered server- side scripts, even if they weren’t aware of it

13  You can create client- or server-side scripts in one of two scripting languages: ◦ VBScript ◦ JavaScript ◦ JavaScript is a scripting language created by Netscape  Internet Explorer supports both scripting languages  Netscape Communicator supports only JavaScript

14  The following is an example of a document that contains HTML and a simple VBScript script  The script displays the message “Hello, world!” in a message box <!-- msgbox(“Hello, world!”) //-->

15  The following is an example of a file that contains HTML and a simple script written in JavaScript  The script displays the message”Hello, world!” in a message box <!-- alert (“Hello, world!”) //-->

16  The following HTML page includes a simple server-side script written in VBScript as shown on page 6 of the textbook  Code Dissection ◦ A Web page can contain HTML tags along with scripts ◦ The line … tells the Web server that this script runs on the server first, before the HTML page can be transmitted to the client ◦ The line … tells the Web server that this script should be transmitted to the client and tells the browser to run this script on the client, rather than on the server ◦ The tag combination tells the Web server to run the script on the server and pass the results to the client

17  The following HTML page includes a simple server- side script written in JavaScript as shown on page 6 of the textbook  Code Dissection ◦ A Web page can contain HTML tags along with scripts ◦ The line … tells the Web server that this script runs on the server first ◦ The line … tells the Web server that this script should be transmitted to the client and tells the browser to run this script on the client, rather than on the server ◦ The tag combination tells the Web server to run the script on the server and pass the results to the client

18  A Web application is a special type of Web site that contains pages of static HTML and server-side scripts that interact with a user  The Web applications that you will encounter in this book share some common attributes  Programmers routinely use objects to create reusable code that can be used in many applications  You can “trim” the size of an online image, by changing the appropriate property

19  Objects also have methods  Properties and methods are useful, but the fun starts when an event, the other main component, enters the scenario  An event occurs when a stimulus affects an object  Events create or modify an object  Once the Application object is created, an event called Application_OnStart starts, in the Global.asa file in the Web application directory

20  Global.asa is a file that contains events that are activated when Application and Session objects are created and when they are destroyed  An Application object’s main job is to store any settings that are the same between sessions  Sessions are special environments that the Web server creates for each user of an application  The sessions themselves are also objects  One is created at the same time that the Application object is being created

21  The Session object contains the environment in which the user interacts with the application  When the user fills in the form and clicks the Submit button, this event results in the creation of a Request object  Once the server receives the Request object, it begins to respond to the request, resulting in the creation of a Response object  The Application, Session, Request, and Response objects are the most important objects in ASP

22  PWS is a Web server that allows you to create and test applications in Windows 98, Windows 2000, and Windows XP  Once you complete your Web application and want to use it over the Internet, you use IIS (Internet Information Server)  PWS is designed only as a development environment to be used to create and test Web applications  You must adapt to and use a Web server’s existing folder structure  To create a PWS virtual directory—look for the Personal Web Server and look for Personal Web Manager ◦ Verify that web publishing is on and click on Advanced icon—the advanced directory dialog box opens ◦ Type in the name of your directory and then type in the full pathnname to the directory (http://localhost/Yourdirectory/register.htm )http://localhost/Yourdirectory/register.htm

23  To create the Register.htm page use the steps on pages 10 and 11 of the handouts  Many text editors such as Notepad attach their own filename extension (.txt in Notepad) to a saved file  Verify that your file does not include a double extension  To create the Register_me.asp script in the VBScript language follow the directions on the page 12 in the handouts

24

25  Code Dissection ◦ The line specifies the scripting language being used. The tells the Web server that the enclosed script code must run before the Web page is transmitted to the browser ◦ The line tells the Web server to create the entire Web page in memory before sending it to the client ◦ The line tells the Web server to insert the contents of the form element txtFirstName

26  The next step in developing a Web application is testing what you have created  To test the new application refer to the procedures on page 13 in the handouts  This sample application is actually an information system; it receives input, processes the input, and provides output

27 1

28  Web pages used to be simple items. You requested a page, the server processed your request, and you then received the page for viewing  After simple static Web pages, the industry moved on to utilize CGI scripts, even with their shortcomings  The term script, or scripting, refers to lines of code that accomplish specific tasks, such as retrieving data from a file 1

29  In programming, objects are discrete entities with two main characteristics: ◦ Properties ◦ Methods  Properties are the data that describe an object  In this class, you will either use Personal Web Server (PWS), or IIS


Download ppt "Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular "

Similar presentations


Ads by Google