Windows XP Professional

Download Report

Transcript Windows XP Professional

Client-side & Server-side
Scripting
©Richard L. Goldman
August 5, 2003
Requires PowerPoint 2002 or
later for full functionality.
2
Simple HTML Web Page
©
Richard L. Goldman

Simple HTML files are interpreted by the
client’s Web browser, formatted and displayed
as a static Web page.
3
Client Computer
Browser
Software
(IE)
Web page
requested
Web Server
Web
Server
Software
(IIS)
Web server
sends Web
page to
client
Browser
renders
Web page
Web Site
Web
Page
(.htm)
Simple Web Page
©
Richard L. Goldman
4
Scripts
©
Richard L. Goldman



Scripts may be included in a Web page to create a dynamic
Web page which allows user interactivity.
Scripts can be written in different languages:
 JavaScript
(IE & Netscape – this is not Java)
 JScript
(IE only - Microsoft version of JavaScript)
 VBScript or VBS (IE only - Visual Basic)
 ECMAScript
(IE & Netscape - Cross-platform language)
(European Computer Manufacturers Association)
Each scripting language requires its own specific interpreter
(engine) to run the script.
5
Client-side Script Tags
©
Richard L. Goldman




Scripts that run on the client’s computer are called Client-side scripts.
Use the <SCRIPT>...</SCRIPT> tags to include the script in a HTML
document.
Use the LANGUAGE attribute to identify the scripting language that you
are using.
<SCRIPT LANGUAGE=“JavaScript1.3”>............</SCRIPT>
<SCRIPT LANGUAGE=“JScript3.0”>..................</SCRIPT>
<SCRIPT LANGUAGE=“VBScript1.3”>...............</SCRIPT>
<SCRIPT LANGUAGE=“VBS”>...........................</SCRIPT>
JavaScript is the default language on most browsers and will be run if a
language is not specified.
Inserting a Script
<HTML>
6
<HEAD>
<TITLE>Mr. Goldman</TITLE>
<SCRIPT LANGUAGE=“JavaScript1.3”>
©
<document.write “<H1>Hello</H1>”;Richard L. Goldman
</SCRIPT>
</HEAD>


Scripts can be placed in
either the Head or the
Body.
Client-side scripts
placed at the end of the
body will allow the page
to be displayed before
the script is run.
<BODY>
<H2>Welcome</H2>
<P>
<H3><I>Sample</I></H3>
</P>
<SCRIPT LANGUAGE=“JavaScript1.3”>
<document.write “<H1>Good By</H1>”;
</SCRIPT>
</BODY>
</HTML>
7
Client Computer
JavaScript Browser
Engine
Software
(IE)
Web page
requested
Web Server
Web
Server
Software
(IIS)
Server sends
Web page
(with script) to
client
Web Site
Web
Page
JavaScript
(.htm)
Client-side JavaScript
©
Richard L. Goldman
8
Client Computer
JavaScript Browser
Engine
Software
(IE)
JavaScript
engine
processes
the script
Web Server
Web
Server
Software
(IIS)
Web
Page
JavaScript
(.htm)
Browser
renders
Web page
Web Site
Web
Page
JavaScript
(.htm)
Client-side JavaScript
©
Richard L. Goldman
9
External Client-side Scripts
©
Richard L. Goldman



Common scripts that are used by many different
web pages may be placed in an external file.
External JavaScript files must be saved with a .js
extension.
External files are called with the source (src)
attribute of the SCRIPT tag.
<SCRIPT language=“JavaScript1.3” src=“myscript.js”>
10
Client Computer
JavaScript Browser
Engine
Software
(IE)
Web page
requested
Web Server
Web
Server
Software
(IIS)
©
Richard L. Goldman
Server sends
Web page (with
script call) to
client
Web Site
Web
Page
Script
Script Call
Call
(.htm)
Client-side External JavaScript
ExtScript
(.js)
11
Client Computer
JavaScript Browser
Engine
Software
(IE)
Web Server
Web
Server
Software
(IIS)
Web
Page
External script
is sent to clientside JavaScript
engine
Script Call
call
(.htm)
©
Richard L. Goldman
Browser calls
external script
Browser
renders
Web page
Web Site
Web
Page
Script call
(.htm)
Client-side External JavaScript
ExtScript
(.js)
12
Client-side Script Engines
©
Richard L. Goldman


The client computer can have multiple types of
script engines.
The client computer is capable of running different
types of scripts concurrently.
13
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
Web Server
Web
Server
Software
(IIS)
VBScript
Engine
ECMAScript
Engine
Web Site
Web
Page
(.htm)
Client Side Script Engines
©
Richard L. Goldman
14
Server-side Script Software
©
Richard L. Goldman



Server-side scripts are designed to be run on a Web
server.
Different manufactures have created different types of
software to implement server-side technology – there is no
standard.
The file extension indicates that they are to be processed
by the server and what software should be used.
Manufacturer
Web Server
Server-side Language/File Extension
Microsoft
Internet Information Server (IIS)
Active Server Page / .asp
Linux/Unix
Apache
PHP: Hypertext Processor / .php
Allaire
Cold Fusion
Cold Fusion Markup language / .cfm
15
Client Computer
Browser
Software
(IE)
ASP page
requested
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
©
Richard L. Goldman
VBScript
Engine
Web server
sends ASP
page to ASP
Engine
Web Site
Active
Server
Page
VBScript
(.asp)
Server-side VBScript (IIS & ASP)
16
Client Computer
Web Server
Browser
Software
(IE)
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
Active
Server
Page
VBScript
ASP page
(less serverside script) is
sent to client
Browser
renders
Web page
(.asp)
Web Site
Active
Server
Page
VBScript
(.asp)
Server-side VBScript
VBScript
engine
processes
the© script
Richard L. Goldman
VBScript
Engine
17
Client Computer
Web Server
Browser
Software
(IE)
Web
Server
Software
(IIS)
Active
Server
Page
(.asp)
ASP
Engine
(asp.dll)
Active
Server
Page
(.asp)
Server-side
scripts allow
for interaction
between client
and server.
Web Site
Active
Server
Page
VBScript
(.asp)
Server-side VBScript
©
Richard L. Goldman
VBScript
VBScript
Engine
18
External Server-side Scripts
©
Richard L. Goldman





Know as – Server Side Include (SSI) files.
Common scripts that are used by many different serverside ASP pages may be placed in a SSI file.
SSI files are saved with an .inc extension (or .asp).
SSI files are called from an ASP file with the include
keyword.
SSI files are located and identified with the file attribute.
<!--#include file=“/scripts/head.inc”-->
19
Client Computer
Browser
Software
(IE)
ASP page
requested
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
©
Richard L. Goldman
VBScript
Engine
Web server
sends ASP
page to ASP
Engine
Web Site
Web
WebPage
ASP Page
Page
Script Call
(.htm)
(.htm)
Server Side VBScript
(.asp)
SSI file
(.inc)
20
Server-side Scripts
©
Richard L. Goldman




With server-side scripts, the script engine only needs to
be on the Web server – a client-side script engine in not
required.
Server-side scripts are never sent to the client computer.
The client can not access or view the script.
Client-side and server-side scripts can be used
concurrently.
Server-side scripts can be written in:
 JavaScript
 JScript
 VBScript
 (Not ECMAScript)
21
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
VBScript
Engine
ECMAScript
Engine
Client-side
script engines
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
Server-side script
engines
Web Site
Web
WebPage
ASP Page
Page
CS Script
SS Script
Script Call
Script Call
(.htm)
(.htm)
Client-side & Server-side Script Engines
(.asp)
JavaScript
Engine
JScript
©
Engine
Richard L. Goldman
VBScript
Engine
22
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
VBScript
Engine
JavaScript
Engine
JScript
©
Engine
Richard L. Goldman
VBScript
Engine
Request
ECMAScript
Engine
Response
Server
Session
Application
Web Site
Web
WebPage
ASP Page
Page
CS Script
SS Script
Script Call
Script Call
(.htm)
(.htm)
Server Side VBScript
(.asp)
ExtScript
(.js)
SSI file
(.inc)
23
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
VBScript
Engine
JavaScript
Engine
JScript
©
Engine
Richard L. Goldman
VBScript
Engine
Request
ECMAScript
Engine
Response
Server
Session
Application
Web Site
Web
WebPage
ASP Page
Page
CS Script
SS Script
Script Call
Script Call
(.htm)
(.htm)
Server Side VBScript
(.asp)
ExtScript
(.js)
SSI file
(.inc)
24
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
VBScript
Engine
JavaScript
Engine
JScript
©
Engine
Richard L. Goldman
VBScript
Engine
Request
ECMAScript
Engine
Response
Server
Session
Application
Web Site
Web
WebPage
ASP Page
Page
CS Script
SS Script
Script Call
Script Call
(.htm)
(.htm)
Server Side VBScript
(.asp)
ExtScript
(.js)
SSI file
(.inc)
25
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
VBScript
Engine
JavaScript
Engine
JScript
©
Engine
Richard L. Goldman
VBScript
Engine
Request
ECMAScript
Engine
Response
Server
Session
Application
Web Site
Web
Page
(.htm)
Server Side VBScript
Active
Server
Page
(.asp)
Server
Side
Include
file
(.inc)
26
Client Computer
JavaScript Browser
Engine
Software
(IE)
JScript
Engine
Web Server
Web
Server
Software
(IIS)
ASP
Engine
(asp.dll)
VBScript
Engine
JavaScript
Engine
JScript
©
Engine
Richard L. Goldman
VBScript
Engine
Request
ECMAScript
Engine
Response
Server
Session
Application
Web Site
Web
Page
(.htm)
Server Side VBScript
Active
Server
Page
(.asp)
Server
Side
Include
file
(.inc)