Upload
rodger-quinn
View
219
Download
2
Tags:
Embed Size (px)
Citation preview
Client-side & Server-side Scripting
©Richard L. Goldman
August 5, 2003
Requires PowerPoint 2002 or later for full functionality.
2
©Richard L. Goldman
Simple HTML Web Page
Simple HTML files are interpreted by the client’s Web browser, formatted and displayed as a static Web page.
3
©Richard L. Goldman
Web ServerClient Computer
Simple Web Page
BrowserSoftware(IE)
WebServerSoftware(IIS)
Web Site
Web Page
(.htm)
Web Page
(.htm)
Web Page
(.htm)
Web Page
(.htm)
Web pagerequested
Web server sends Web page to client
Browser renders Web page
4
©Richard L. Goldman
Scripts
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
©Richard L. Goldman
Client-side Script Tags 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.
6
©Richard L. Goldman
Inserting a Script <HTML>
</HTML>
<HEAD>
</HEAD>
<BODY>
</BODY>
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.
<TITLE>Mr. Goldman</TITLE>
<H2>Welcome</H2><P><H3><I>Sample</I></H3></P>
<SCRIPT LANGUAGE=“JavaScript1.3”> <document.write “<H1>Hello</H1>”;</SCRIPT>
<SCRIPT LANGUAGE=“JavaScript1.3”> <document.write “<H1>Good By</H1>”;</SCRIPT>
7
©Richard L. Goldman
Web ServerClient Computer
Client-side JavaScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
Web Site
Web pagerequested
Web Page
(.htm)
Web Page
(.htm)
JavaScript
Web Page
(.htm)
Web Page
(.htm)
JavaScript
Server sends Web page (with script) to client
JavaScriptEngine
8
©Richard L. Goldman
Web ServerClient Computer
Client-side JavaScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
Web Site
Browser renders Web page
Web Page
(.htm)
Web Page
(.htm)
JavaScript
Web Page
(.htm)
Web Page
(.htm)
JavaScript
JavaScriptEngine
JavaScript
JavaScript engine processes the script
9
©Richard L. Goldman
External Client-side Scripts
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
©Richard L. Goldman
Web ServerClient Computer
Client-side External JavaScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
Web Site
Web pagerequested
Web Page
(.htm)
Web Page
(.htm)
Script Call
Web Page
(.htm)
Web Page
(.htm)
Script Call
Server sends Web page (with script call) to client
ExtScript (.js)
ExtScript (.js)
JavaScriptEngine
11
©Richard L. Goldman
Web ServerClient Computer
Client-side External JavaScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
Web Site
Browser renders Web page
Browser calls external script
Web Page
(.htm)
Web Page
(.htm)
Script Call
Web Page
(.htm)
Web Page
(.htm)
Script call
ExtScript (.js)
ExtScript (.js)
JavaScriptEngine
Script call
External script is sent to client-side JavaScript engine
ExtScript (.js)
ExtScript (.js)
12
©Richard L. Goldman
Client-side Script Engines
The client computer can have multiple types of script engines.
The client computer is capable of running different types of scripts concurrently.
13
©Richard L. Goldman
Web ServerClient Computer
Client Side Script Engines
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ECMAScriptEngine
Web Page
(.htm)
Web Page
(.htm)
Web Site
Web Page
(.htm)
Web Page
(.htm)
14
©Richard L. Goldman
Server-side Script Software
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
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.
15
©Richard L. Goldman
Web ServerClient Computer
Server-side VBScript (IIS & ASP)
BrowserSoftware(IE)
WebServerSoftware(IIS)
ASPEngine(asp.dll)
VBScriptEngine
Web Site
ASP pagerequested
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)VBScript
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)VBScript
Web server sends ASP page to ASP Engine
16
©Richard L. Goldman
Web ServerClient Computer
Server-side VBScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
ASPEngine(asp.dll)
VBScriptEngine
Web Site
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)VBScript
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)VBScript
Browser renders Web page
ASP page (less server-side script) is sent to client
VBScript engine processes the script
17
©Richard L. Goldman
Web ServerClient Computer
Server-side VBScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
ASPEngine(asp.dll)
VBScriptEngine
Web Site
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)VBScript
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
VBScript
Server-side scripts allow for interaction between client and server.
18
©Richard L. Goldman
External Server-side Scripts
Know as – Server Side Include (SSI) files. Common scripts that are used by many different server-
side 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
©Richard L. Goldman
Web ServerClient Computer
Server Side VBScript
BrowserSoftware(IE)
WebServerSoftware(IIS)
Web Page
(.htm)
Web Page
(.htm)
ASPEngine(asp.dll)
VBScriptEngine
Web Site
Web Page
(.htm)
Web Page
(.htm)SSI file (.inc)
SSI file (.inc)
ASP Page
(.asp)
ASP Page
(.asp)
Script Call
ASP Page
(.asp)
ASP Page
(.asp)
Script Call
ASP pagerequested
Web server sends ASP page to ASP Engine
20
©Richard L. Goldman
Server-side Scripts
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
©Richard L. Goldman
Web ServerClient Computer
Client-side & Server-side Script Engines
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ECMAScriptEngine
ASPEngine(asp.dll)
JavaScriptEngine
VBScriptEngine
JScriptEngine
Web Site
Client-side script engines
Server-side script engines
Web Page
(.htm)
Web Page
(.htm)
Web Page
(.htm)
Web Page
(.htm)
Script Call
CS Script
ASP Page
(.asp)
ASP Page
(.asp)
SS Script
Script Call
22
©Richard L. Goldman
Web ServerClient Computer
Server Side VBScript
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ECMAScriptEngine
Web Page
(.htm)
Web Page
(.htm)
ASPEngine(asp.dll)
JavaScriptEngine
VBScriptEngine
JScriptEngine
Request
Response
Server
Session
Application
Web Site
Web Page
(.htm)
Web Page
(.htm)
Script Call
CS Script
ASP Page
(.asp)
ASP Page
(.asp)
SS Script
ExtScript (.js)
ExtScript (.js)
SSI file (.inc)
SSI file (.inc)
Script Call
23
©Richard L. Goldman
Web ServerClient Computer
Server Side VBScript
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ECMAScriptEngine
Web Page
(.htm)
Web Page
(.htm)
ASPEngine(asp.dll)
JavaScriptEngine
VBScriptEngine
JScriptEngine
Request
Response
Server
Session
Application
Web Site
Web Page
(.htm)
Web Page
(.htm)
Script Call
CS Script
ASP Page
(.asp)
ASP Page
(.asp)
SS Script
ExtScript (.js)
ExtScript (.js)
SSI file (.inc)
SSI file (.inc)
Script Call
24
©Richard L. Goldman
Web ServerClient Computer
Server Side VBScript
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ECMAScriptEngine
Web Page
(.htm)
Web Page
(.htm)
ASPEngine(asp.dll)
JavaScriptEngine
VBScriptEngine
JScriptEngine
Request
Response
Server
Session
Application
Web Site
Web Page
(.htm)
Web Page
(.htm)
Script Call
CS Script
ASP Page
(.asp)
ASP Page
(.asp)
SS Script
ExtScript (.js)
ExtScript (.js)
SSI file (.inc)
SSI file (.inc)
Script Call
25
©Richard L. Goldman
Web ServerClient Computer
Server Side VBScript
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
ECMAScriptEngine
Web Page
(.htm)
Web Page
(.htm)
ServerSideIncludefile (.inc)
ServerSideIncludefile (.inc)
ASPEngine(asp.dll)
JavaScriptEngine
VBScriptEngine
JScriptEngine
Request
Response
Server
Session
Application
Web Site
Web Page
(.htm)
Web Page
(.htm)
26
©Richard L. Goldman
Web ServerClient Computer
Server Side VBScript
BrowserSoftware(IE)
JavaScriptEngine
VBScriptEngine
JScriptEngine
WebServerSoftware(IIS)
ActiveServerPage
(.asp)
ActiveServerPage
(.asp)
ECMAScriptEngine
Web Page
(.htm)
Web Page
(.htm)
ServerSideIncludefile (.inc)
ServerSideIncludefile (.inc)
ASPEngine(asp.dll)
JavaScriptEngine
VBScriptEngine
JScriptEngine
Request
Response
Server
Session
Application
Web Site
Web Page
(.htm)
Web Page
(.htm)