E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2.

Slides:



Advertisements
Similar presentations
Other Web Application Development Technologies. PHP.
Advertisements

Other Web Application Development Technologies. PHP.
Overview Environment for Internet database connectivity
Lecture 11 Server Side Interaction
Lecture plan Information retrieval (from week 11)
DT228/3 Web Development WWW and Client server model.
Session 13 Active Server Pages (ASP) Matakuliah: M0114/Web Based Programming Tahun: 2005 Versi: 5.
IIS Technologies.
Server-Side vs. Client-Side Scripting Languages
1 Chapter 12 Working With Access 2000 on the Internet.
ASP Tutorial. What is ASP? ASP (Active Server Pages) is a Microsoft technology that enables you to make dynamic and interactive web pages. –ASP usually.
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.
28/1/2001 Seminar in Databases in the Internet Environment Introduction to J ava S erver P ages technology by Naomi Chen.
DT211/3 Internet Development Application Internet Development Application.
Week 2 IBS 685. Static Page Architecture The user requests the page by typing a URL in a browser The Browser requests the page from the Web Server The.
Website Development with PHP and MySQL Introduction.
Chapter 11 ASP.NET JavaScript, Third Edition. 2 Objectives Learn about client/server architecture Study server-side scripting Create ASP.NET applications.
Computer Science 101 Web Access to Databases Overview of Web Access to Databases.
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
2440: 141 Web Site Administration Web Server-Side Programming Professor: Enoch E. Damson.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Overview of JSP Technology. The need of JSP With servlets, it is easy to – Read form data – Read HTTP request headers – Set HTTP status codes and response.
DAT602 Database Application Development Lecture 15 Java Server Pages Part 1.
Server Side Scripting Norman White. Where do we do processing? Client side – Javascript (embed code in html) – Java applets (send java program to run.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
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)
Dynamic Web Sites Chris North cs3724: HCI. Presentations matt ketner, sam altman, mike gordon Vote: UI Hall of Fame/Shame?
Dr. Azeddine Chikh IS444: Modern tools for applications development.
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.
3/8/00asp00 1 Active Server Pages from Microsoft Nancy McCracken Northeast Parallel Architectures Center at Syracuse.
Nic Shulver, Intro: Developing Server Applications What is a server? Many types of server – File server – file: networked file.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Elements of ASP Documents Adapted from MCDN Web Workshop ( and Webmonkey’s Introduction to Active.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
Website Design Lecture 1. Outline Introduction to the module Outline of the Assessment Schedule Lecture Static XHTML, client side and server side Why.
Active Server Pages  In this chapter, you will learn:  How browsers and servers interacted on the Internet when the Internet first became popular 
Chapter 6 Server-side Programming: Java Servlets
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Introducing ASP.NET 2.0. Internet Technologies WWW Architecture Web Server Client Server Request Response Network HTTP TCP/IP PC/Mac/Unix + Browser (IE,
1 MSCS 237 Overview of web technologies (A specific type of distributed systems)
CS 4720 Dynamic Web Applications CS 4720 – Web & Mobile Systems.
Enterprise PHP - Introduction Enterprise Client-Server Development with PHP Nic Shulver, FCES, Staffordshire University A fifteen credit module based on.
Introduction to JavaScript CS101 Introduction to Computing.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
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.
The Module Road Map Assignment 1 Road Map We will look at… Internet / World Wide Web Aspects of their operation The role of clients and servers ASPX.
David Lawrence 7/8/091Intro. to PHP -- David Lawrence.
Web Design and Development. World Wide Web  World Wide Web (WWW or W3), collection of globally distributed text and multimedia documents and files 
 Previous lessons have focused on client-side scripts  Programs embedded in the page’s HTML code  Can also execute scripts on the server  Server-side.
Internet Applications (Cont’d) Basic Internet Applications – World Wide Web (WWW) Browser Architecture Static Documents Dynamic Documents Active Documents.
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. 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.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
ASP-2-1 SERVER AND CLIENT SIDE SCRITPING Colorado Technical University IT420 Tim Peterson.
1) PHP – Personal Home Page Scripting Language 2) JavaScript.
7-1 Active Server and ADO Colorado Technical University IT420 Tim Peterson.
COSC 2328 – Web Programming.  PHP is a server scripting language  It’s widely-used and free  It’s an alternative to Microsoft’s ASP and Ruby  PHP.
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.
Section 6.3 Server-side Scripting
Web Concepts Lesson 2 ITBS2203 E-Commerce for IT.
WWW and HTTP King Fahd University of Petroleum & Minerals
ASP Explained By: Sarbjit Kaur.
PHP / MySQL Introduction
The Request & Response object
Chapter 27 WWW and HTTP.
Introduction to Servlets
Intro to PHP.
PHP: Hypertext Preprocessor
Presentation transcript:

E-Commerce CMM503 – Lecture 8 Stuart Watt Room C2

Summary of this week Learning outcomes –A basic understanding of server-side scripting, and its main differences from client-side scripting –Able to set up a basic site using Microsofts Internet Information Services –A basic understanding of the Active Server Pages object model

Part 1 Server-side scripting and Internet Information Services

1 An overview of server-side scripting

1.1 Why use server-side scripting? When you want to give users access to a database When you want people to be able to share data with each other When you want pages to be dynamically generated, but when you cannot be completely certain that peoples browsers support JavaScript When you want to deliver more complex behaviour than you can with JavaScript When you want to use more processing power to generate the page than you could reasonably expect the user to have

1.2 Main server-side scripting technologies CGI (or: Common Gateway Interface) –Portable, runs outside server, slow PHP (or: PHP: Hypertext Preprocessor) –Portable, good for databases, medium to fast Cold Fusion –Proprietary, portable, good for databases Active Server Pages (or ASP) –Proprietary, Microsoft-specific Java Server Pages (or JSP) –Portable, good for Java code

2 Active Server Pages Solves almost all the problems associated with static HTML and client-side scripting. Advantages –It is simple, you only write your code in the HTML page itself. –No compiling, no complex interfacing, quick and easy to update Disadvantages –Mostly Microsoft-specific (although the Apache clone is very good)

2.1 Active Server Pages (ASP) Are processed in response to a client request –Server-side scripting Are processed by an ActiveX component –A scripting engine Have the file extension.asp Contains HTML tags and scripting code –Scripts are code between VBScript is the most widely used language –You can also use JavaScript, or even Perl!

2.2 ASP ASP provides a server-side scripting environment This includes: –Reading information from an HTTP request –Customising an HTTP response –Storing information about a user –Extracting the capabilities of the users browser

2.3 How does ASP work? Client Server Script processor Request Response

2.4 ASP Vs (D)HTML The main difference between ASP and (D)HTML pages is the location where the script is run. –HTML, DHTML, or client-side script, is run on the client, in the browser, after the page is sent from the server –ASP, or server-side script, is run on the server before the page is sent to the browser. The Web server processes the script and generates the HTML pages that are returned to the Web browser

2.5 Coding: ASP Vs. DHTML Server-side script and client-side script look very similar because they both use the same languages, VBScript, JavaScript, or even Perl. Server side scriptClient side script RGU Home The time here is RGU Home The time here is Document.Write(time()).

2.6 Coding: ASP v DHTML In practice, the extended tag makes them even closer! Server side scriptClient side script RGU Home The time here is <SCRIPT LANGUAGE=JavaScript RUNAT=server> Response.Write(time() ). RGU Home The time here is Document.Write(time() ).

2.7 A Simple ASP Example A Simple ASP Example Simple ASP Example

2.9 Example of an ASP error message Look for the technical information! It will tell you where the error was

2.10 How does ASP work inside? ASP files are compiled into procedures –HTML is turned into a print statement –Other code is embedded directly Advantages –HTML editors (e.g., Dreamweaver) can be used to create ASP pages –Program control flow is applied to HTML –Much improved performance over simpler server-side scripting such as CGI

2.11 ASP pages as procedures First time around: –The ASP file is read from disk –It is then compiled into a program, and a copy of the compiled version kept in a cache Future references to the same page: –Read the compiled procedure and run it immediately

3. Setting up sites using Internet Information Services

3.1 Initial screen for Internet Information Services

3.2 The Internet Information Services control panel

3.3 To create a new virtual directory

3.4 The virtual directory wizard

3.5 The virtual directory wizard

3.6 Setting the default scripting language to JavaScript

Part 2 Active Server Pages Basics of the object model

4. COM objects in one slide Objects consist of: –Properties And fields – these are attributes of the object –Collections Which give you lists of things –Methods Like Document.Write in JavaScript, they ask objects to do things –Events Are a way of keeping track of things happening to objects behind the scenes. Rarely used in ASP, except for sessions

4.1 ASP Built-in Objects Request Response Session Application Server ObjectContext

4.1.1 ASP Built-in Objects Request –Retrieves the values that the browser passes to the server during an HTTP request Response –Controls what information is sent to a browser in the HTTP response message

4.1.2 ASP Built-in Objects Session –Used to manage and store information about a particular user session Application –Used to manage and store information about the Web application

4.1.3 ASP Built-in Objects Server –Provides access to resources that reside on a server ObjectContext –Used to commit or abort a transaction managed by Microsoft Transaction Server (MTS) for ASP pages that run in a transaction

4.1.4 ASP Built-in Objects RequestRetrieve information passed from the browser to the server ResponseSend output to the browser SessionStore information for a specific user ApplicationShare information among all users of your application ServerWork with the properties and methods of components on the server

4.2 What is a collection? A collection is simply a set of objects –They may be Indexed by number (usually from 1, but not always) Indexed by string A collection is an object in its own right –Properties: Count, Item –Methods: Add, Remove

4.3 Request Object Collections ClientCertificate Cookies Form QueryString ServerVariables

4.3.1 Request Object ClientCertificate –The values of the certification fields in the HTTP request Cookies –The values of cookies sent in the HTTP request

4.3.2 Request Object Form –The values of form elements posted to the body of the HTTP request message by the form's POST method Well see an example in a moment

4.3.3 Form Collection Ice cream parlour Name: Favourite Flavour: Mint Vanilla Coffee

Using form collections Access to named fields: Request.Form.Item("name") Request.Form.Item("flavour") Access to the form collection: var myForm = Request.Form; var myCount = myForm.Count; for (my index = 1; index <= myCount; index++) { … }; –See the example: ice_cream_form.asp

Full data recording script Ice cream results Field name Field value <% var myForm = Request.Form(); var myCount = myForm.Count(); for (index = 1; index <= myCount; index++) { %> <% }; %>

4.3.4 Request Object QueryString –The values of variables in the HTTP query string, specifically the values following the question mark (?) in an HTTP request ServerVariables –The values of predetermined Web server environment variables See an example: servervariables.aspservervariables.asp

4.4 Response Object Buffer –indicates whether a response is buffered Expires –Specifies the length of time before a page cached on a browser expires. If the user returns to the same page before it expires, the cached version is displayed

4.4.1 Write method Really important!! –The Write method of Response object adds text to the HTTP response message if (Request.Form.Item("name") == "Stuart") { Response.Write(" No room for you here!"); }; –You can put any data in the parameter you like, but strings are most common

The Write shortcut The Write method is so common theres a short cut: – can be written: – Note that this doesnt end with a semicolon! This is much shorter, and is preferred for simple expressions and values

Write method var myCount = Request.Form.Count; for (index = 1; index <= myCount; index++) { Response.Write(Request.Form.Item(index)); }; ); %> The string returned by the Write method cannot contain the characters %> in an HTML tag, so the escape sequence %\> is used instead

4.4.2 Redirect method Instead of sending content from the response message to the user, the Redirect method of Response object can be used to redirect the user to another URL. The URL specifies the absolute or relative location to which the browser is redirected. <% if (Request.ServerVariables("HTTP_UA_PIXELS") == "640x480") { Response.Redirect("poorscreen.htm"); } else { Response.Redirect("nicescreen.htm"); }; %>

5. Session Tracking and Cookies Enable a web server to distinguish between clients –A server performs session tracking by keeping track of when a specific user visits a site. A unique session ID will be assigned to the user –Cookies are small files sent by an ASP page (or another similar technology, such as a Perl CGI script) as part of a response to a client

5.1 The core of an application: global.asa Defines events for sessions and the application –Events are triggered by a change in the environment function Session_OnStart { Application.Lock(); var visits = Application.Contents("NumberOfVisitors"); Application.Contents("NumberOfVisitors") = visits + 1; Application.Unlock(); };

directives in processing directives –Send information to server about how to process.asp @LANGUAGE is most frequently used –Specifies the scripting language to be used in the.asp file. For example: sets the scripting language to VBScript

7. Summary Active Server Pages versus JavaScript –Server-side versus client-side Easier to access databases and other programs Better control of the scripting environment For more information: –See the documentation installed with IIS: