29
Introduction and Principles Web Server Scripting

Introduction and Principles Web Server Scripting

Embed Size (px)

Citation preview

Page 1: Introduction and Principles Web Server Scripting

Introduction and Principles

Web Server Scripting

Page 2: Introduction and Principles Web Server Scripting

Outcomes

• Understand the principles of web server scripting• Be able to use web server scripting• Understand the issues affecting web server

scripting

Page 3: Introduction and Principles Web Server Scripting

What is server side scripting?

• Server-side scripting is a web server technology in which a user's request is verified by running a script directly on the web server to generate dynamic web pages.

• It is used to create dynamic web pages• Unlike client side scripting, the code is secure as it

cannot be viewed on the client

Page 4: Introduction and Principles Web Server Scripting

Static web pages

• The server contain .HTML files• These are served to the client browser on request• The local browser may have some interaction via

client-side scripting (JavaScript)• The HTML pages are fixed and cannot be altered

to match individuals requests

Page 5: Introduction and Principles Web Server Scripting

Dynamic model

• HTML pages are generated when they are requested

• The basic page is done in a scripting language and uses HTML and CSS to determine static content and appearance

• The variable data is generated by scripts (an interpreted program) running on the web server

Page 6: Introduction and Principles Web Server Scripting

An example

List generated by scripts

Clicking here will run a script using the new

parameters to generate a new list

Clicking here will run a script to add the

product to a basket and update the basket

status on this page

Page 7: Introduction and Principles Web Server Scripting

Other uses

• Updating databases• Interacting with forums• Gathering user statistics• Managing profiles• Blogging• Sharing (upload to Web 2.0 applications)

Page 8: Introduction and Principles Web Server Scripting

How does it work?

Page 9: Introduction and Principles Web Server Scripting

Activity

• There are a variety of web server scripting languages

• Find 5 scripting languages and create a table which shows:• Open or proprietary• Free or paid for• Main features• Claimed advantages

• You must include PHP

Page 10: Introduction and Principles Web Server Scripting

ASP

• Active Server Pages (ASP)  • A server-side scripting environment from

Microsoft• Uses a file extension of .asp. • Scripts are usually written in VBScript• ASP will normally run only on Microsoft servers

Page 11: Introduction and Principles Web Server Scripting

ASP.NET

• The successor to Microsoft's ASP• Allows programmers to create web applications

using any scripting or programming language supported by the .NET Framework.

• The main building blocks are pages known as web forms, which contain definitions for server-side Web Controls and User Controls,

• Web forms have the file extension .aspx

Page 12: Introduction and Principles Web Server Scripting

ColdFusion Markup Language (CFML)

• A scripting language originally introduced by Adobe Systems in 1995

• Enables web developers to embed database commands and other server-side scripting elements within standard HTML or XHTML

• Pages in a ColdFusion web application are pre-processed by the ColdFusion Application Server when requested by a client browser

Page 13: Introduction and Principles Web Server Scripting

Perl

• A high-level, interpreted programming language • A procedural programming language loosely based

on C • Used for the creation of web applications, especially

those where database access is required. • Perl is free software

Page 14: Introduction and Principles Web Server Scripting

JavaServer Pages (JSP)

• A Java technology similar to ASP• Used to create dynamically generated web pages

by embedding Java programming code in HTML or XHTML documents

• A JavaServerPage is compiled into a Java servlet by an application server, rather than being interpreted

• A servlet is a Java program that executes on the server to create dynamic web pages.

Page 15: Introduction and Principles Web Server Scripting

PHP

• A widely-used scripting language • PHP is free software released • PHP code can be embedded into HTML or

XHTML documents • It is executed on the server to generate dynamic

web content. • PHP is frequently used together with MySQL, and

is one of the key technologies in the

Page 16: Introduction and Principles Web Server Scripting

Client side and server side

• Client side• Reduces web traffic as processing done on client• Good for

• Form validation• User aids (drop downs, hover etc)• Local navigation

• Server side• Can use centralised server resources eg databases• No client plug-ins required, runs in any browser• No load on client, can use powerful server hardware• Applications do not need distributing

Page 17: Introduction and Principles Web Server Scripting

Combined use

• Build efficient applications• Choose to do the processing in the most

appropriate location• Choose where to keep up to date multi use data• Choose how to optimise the user experience:

• Performance• Appearance• Function

Page 18: Introduction and Principles Web Server Scripting

Summary: web server scripting

Advantages• Interpreted, low processing

overhead• Interpreter is integrated into

web server, so it is fast• Secure, code runs on server• Content based on live data• Can use basic, eg phone,

browsers as processing is server side

Disadvantages• Debugging tools can be

scarce• Can be more difficult to

develop• Requires a running server to

test• Has no direct control over

the user interface

Page 19: Introduction and Principles Web Server Scripting

19

Web Servers (IIS and Apache)Outline9.1 Introduction9.2 HTTP Request Types9.3 System Architecture9.4 Client-Side Scripting versus Server-Side Scripting9.5 Accessing Web Servers9.6 Web Resources

Page 20: Introduction and Principles Web Server Scripting

20

Objectives

• In this lesson, you will learn:• To understand a Web server’s functionality.• To introduce Microsoft Internet Information Services

(IIS) and Apache Web server.• To learn how to request documents from a Web server.

Page 21: Introduction and Principles Web Server Scripting

21

9.1  Introduction

• Web server: Responds to client requests by providing resources

• URI (Uniform Resource Identifier)

• Web server and client communicate with platform-independent Hypertext Transfer Protocol (HTTP)

Page 22: Introduction and Principles Web Server Scripting

22

IIS 5.0 IIS 6.0 Apache Web server Company Microsoft

Corporation Microsoft Corporation

Apache Software Foundation

Version 5.0 6.0 2.0.47 Released 2/17/00 3/28/03 7/10/03 Platforms Windows 2000,

Windows XP Windows Server 2003 Windows NT/2000/XP,

Mac OS X, Linux and other UNIX-based platforms, experimentally supports Windows 95/98

Brief description

The most popular Web server for Windows 2000.

The newest release of IIS from Microsoft.

Currently the most popular Web server.

Price Included with Windows 2000 and Windows XP.

Included with Windows Server 2003

Freeware.

Web servers discussed in this chapter.

Page 23: Introduction and Principles Web Server Scripting

23

9.2  HTTP Request Types

• get :• Get (retrieves) information from a server• i.e: retrieve HTML document or image, fetch search results• Sends information as part of URL

• www.search-engine.com/search?name=value

• post:• Post (sends) data to a server• i.e: authentication information, form data.• Sends form data as an HTTP message, not as part of URL

Page 24: Introduction and Principles Web Server Scripting

24

• Browsers often cache (save on disk) Web pages• Quickly reload the page (speed up browsing experience)• Browser asks the server if the document has changed or

expired• If not, the browser loads the document from the cache

Page 25: Introduction and Principles Web Server Scripting

25

9.3  System Architecture

• Multi-tier application (n-tier application):• Information tier (data or bottom tier)

• Maintains data for the application• Stores data in a relational database management system

(RDBMS)• Middle tier

• Implements business logic and presentation logic• Control interactions between application clients and

application data• Client tier (top tier)

• Application’s user interface• Users interact directly with the application through the client

tier

Page 26: Introduction and Principles Web Server Scripting

26

Information tier (data or bottom tier)Middle tierClient tier (top tier)

Page 27: Introduction and Principles Web Server Scripting

27

9.4  Client-Side Scripting versus Server-Side Scripting

• Client-side scripts• Validate user input• Reduce requests needed to be passed to server• Access browser• JavaScipt, VBScript

• Server-side scripts• Executed on server• Generate custom response for clients• Wide range of programmatic capabilities• Access to server-side software that extends server

functionality

Page 28: Introduction and Principles Web Server Scripting

28

9.5  Accessing Web Servers

• Request documents from Web servers• know the Host names• Local Web servers

• Access through machine name or localhost• Remote Web servers

• Access through machine name• Domain name or Internet Protocol (IP) address

• Domain name server (DNS): Computer that maintains a database of host names and their corresponding IP address

Page 29: Introduction and Principles Web Server Scripting

29

9.6  Web Resources

• www.microsoft.com/msdownload/ntoptionpack/askwiz.asp• www.w3.org/Protocols• www.apache.org• httpd.apache.org• httpd.apache.org/docs-2.0• www.apacheweek.com• linuxtoday.com/stories/18780.html• www.iisanswers.com• www.iisadministrator.com