COMP 3121 EBusiness Technologies Richard Henson University of

  • Slides: 43
Download presentation
COMP 3121 E-Business Technologies Richard Henson University of Worcester October 2010

COMP 3121 E-Business Technologies Richard Henson University of Worcester October 2010

Week 3 – Early Web Applications and scope for E-commerce n Objectives: Ø Compare

Week 3 – Early Web Applications and scope for E-commerce n Objectives: Ø Compare and contrast embedded code for client-only applications & server scripting Ø Explain how Java. Script relates to Sun Java, and why Java. Script is the preferred language for many Internet developers Ø Explain how VBScript can to be used in serverscripting, and why it has fallen out of favour Ø Set up a software development environment for producing client-server websites with remote database support

Client-side: going beyond HTML… n HTML cannot do everything! Ø sequence of code… Ø

Client-side: going beyond HTML… n HTML cannot do everything! Ø sequence of code… Ø not a programming language n Tim Berners-Lee based it on SGML - a formatting language Ø never intended to be for programming Ø doesn’t allow definition of new “objects” (need a more flexible language like XML) n Programming languages also deal with: Ø selection (choice from different code sequences) Ø iteration (repeating the same code again and again)

Introducing Selection and Iteration into a HTML document n All about embedding programming code

Introducing Selection and Iteration into a HTML document n All about embedding programming code into a HTML file Ø generally, embedded code is included in <head> Ø sometimes, a chunk of code included within <body> n Normally… programming functions Ø defined in <head> Ø called from the within <body> n As previously explained, languages used: Ø Visual BASIC (as VBScript) Ø Java (as Java. Script)

Rapid Generation of Clientside embedded code n Apart from writing the code for yourself…

Rapid Generation of Clientside embedded code n Apart from writing the code for yourself… Ø cut-and-paste from one of the many sites on the Internet offering free (or paid for) code n Alternatively, a tool could be used to generate the code at the click of a button: Ø e. g. Dreamweaver or Visual Studio n This is fine for one-off use, but could cause problems e. g. : Ø reusing/modifying the code in a different context Ø don’t understand what the code is doing…

Interpreted and Compiled Languages n n Programming (source) code must be converted into “machine

Interpreted and Compiled Languages n n Programming (source) code must be converted into “machine code” before it can be understood and acted on by the CPU This can be done in two ways: Ø convert whole program (using a compiler) and save it in a file Ø leave program as it is, and convert it (using an interpreter) one line at a time when it is needed n Compiled code generally occupies much more space than source code Ø so of more limited use on the Internet (esp. early days). . .

How do Browsers cope with source code? n Designed to use interpretation on HTML

How do Browsers cope with source code? n Designed to use interpretation on HTML code Ø reads one line of HTML key words and their parameters and uses HTML interpreter to convert (or interpret) that line into CPU instructions Ø reads & interprets next line… and so on… Ø CPU does further processing and sends commands to the video card which creates the visual display

Java Programming Language n Developed by Sun Microsystems Ø intention of combining best features

Java Programming Language n Developed by Sun Microsystems Ø intention of combining best features of two most popular languages: » “C” (compiled language) » BASIC (generally an interpreted language - although run-time versions are available) n Used in two different ways: Ø Applets - small pieces of code that can fit into other programs (e. g. HTML documents) Ø Programs - like C programs but generally more compact (source code takes up less space than compiled code)

An Instant Use for Java… n In 1994: Øthe network companies weren’t interested in

An Instant Use for Java… n In 1994: Øthe network companies weren’t interested in browser power… » network managers concerned with controlling users!! » applets offered far too much user control Øthe Internet (thanks to the Tim and the Web) was evolving in a different direction… » all about “freedom” for the user » what Java offered would enrich this…

Day of Enlightenment? n Quote from Sun’s own website: Ø“… Daily, momentum behind the

Day of Enlightenment? n Quote from Sun’s own website: Ø“… Daily, momentum behind the new vision grew. ØWeb. Runner [early Java application named after Blade. Runner] was just a demo, but an impressive one: ØIt brought to life, for the first time, animated, moving objects and dynamic executable content inside a Web browser. ØThat had never been done. ”

Integration of Java and Netscape n Subsequent to Web. Runner demo. . . ØJava

Integration of Java and Netscape n Subsequent to Web. Runner demo. . . ØJava code started being used to animate objects displayed on a Netscape browser n BIG breakthrough… ØThe Internet now had the potential to rival television as a mass medium! Netscape and Sun joined forces n Shares in both companies skyrocketed! n

Java. Script and JScript n Early 1995: Ø Sun and Netscape released Java. Script

Java. Script and JScript n Early 1995: Ø Sun and Netscape released Java. Script Ø Java. Script interpreter included with Netscape browser n Microsoft (nearly too late!) saw they were being usurped Ø Windows 95 delayed, and became Internet ready with language interpretation beyond HTML almost as an afterthought… Ø developers very busy in 1996! » came up with JScript… and Active. X n Netscape & Sun infuriated about JScript Ø refused to include support in their browser! » “Browser wars” began. . . Ø eventually, Microsoft withdrew JScript and concentrated on developing C into C#

History of Visual BASIC n n Microsoft’s first success was putting BASIC into a

History of Visual BASIC n n Microsoft’s first success was putting BASIC into a micro as a 32 K ROM (1976 -7) “Visual” BASIC evolved in early 1990 s Ø derisory comments by purists Ø increasingly popular with (some) developers… n Gates responded to criticisms that earlier versions of BASIC lacked programming structure Ø Visual BASIC to some extent object-orientated Ø interface developments made it very flexible to use Ø but… ultimately, it was still BASIC…

What is VBScript? n Scaled down version of Visual Basic Øno operating system calls

What is VBScript? n Scaled down version of Visual Basic Øno operating system calls Provides a powerful, easy to learn tool that can be used to add interaction to web pages n For developers experienced in VB or VBA (Visual Basic for Applications), transition to VBScript is straightforward n Øshould be immediately productive!

What is Active. X®? n A more successful Microsoft invention… Ø started out as

What is Active. X®? n A more successful Microsoft invention… Ø started out as “compiled” (i. e. “run-time”) VB code n Known as a “control” Ø contains NO source code so can’t be embedded in HTML, but can be called from a HTML file Ø allows compiled (i. e. executable) code to talk to host applications Ø difficult to “hack” the code if source code not available n As the scripts are compiled into executable versions the source language is therefore irrelevant Ø languages other than VB can be used…

Client-Server web applications & Server Scripts § Client-server web applications usually require: 1. a

Client-Server web applications & Server Scripts § Client-server web applications usually require: 1. a web server, for interpreting or compiling then processing the scripts 2. a server-end database to provide and store data 3. physical & logical connections between serverscripts, client-end input forms and server-end database 4. clearly defined locations for gathering input data at client-end, for server scripts, and for database(s)

Writing Server Scripts n Server code can be embedded directly into the body of

Writing Server Scripts n Server code can be embedded directly into the body of the web page Ø A Command is needed to inform the browser » (1) that non-HTML code is about to be used » (2) when next code reverts to HTML n With. asp scripts… Ø the command to start the script is <% Ø to end the script… %> n With. php scripts… Ø <? php starts the script Ø ? > ends the script

Server Scripts and “Localhost” n n No matter which scripting type is used, the

Server Scripts and “Localhost” n n No matter which scripting type is used, the code can be tested locally on a computer running a web server that can understand that type of script The secret is to use “localhost” in the URL at the browser window Ø (localhost = path to the server scripting root folder) n n A typical URL for testing such a script (scriptname. aspx) locally could then be: http: //localhost/scriptname. aspx

Using Software Tools for Client-Server Development n n “localhost” maps directly to the home

Using Software Tools for Client-Server Development n n “localhost” maps directly to the home folder configured on the local web server It is therefore possible to have “local site” (page development) and “remote site” (script testing on server) both happening on the same machine. Tools can be configured to allow Ø easy “local site” and “remote site” management including up & downloading Ø server scripts to run directly without having to use localhost to check each time Ø the creation of server scripts in a number of different formats (asp, asp. net, php, etc…)

Development of. NET framework for Server Scripting n BASIC and VB were very much

Development of. NET framework for Server Scripting n BASIC and VB were very much a part of Microsoft’s strategy, until circa 1999/2000 when the use of raw source code became a security issue Ø Gates realised that e-business and e-commerce would never be reliable without using secure (and therefore compiled) code Ø Microsoft rejected their previous strategy which used source VB code and an interpreter program within IIS n Result: . net Framework & ASP. NET: Ø VB evolved into the more object oriented (and complied) VB. NET n Server equivalent of Active. X controls could now be used/developed for the server end… Ø basis for » . net server-side controls » the ubiquitous use of compiled languages

Similarities between ASP and ASP. NET scripts n Despite fundamental differences between asp and

Similarities between ASP and ASP. NET scripts n Despite fundamental differences between asp and aspx scripts, IIS v 5 (released in 2001, for Windows XP) was designed so these script types could run side by side on the IIS platform: Ø asp: IIS executes scripts through ADO objects and a VB interpreter Ø aspx: uses. net framework on top of IIS: » ignores. asp files » “by default” (can be changed) uses the same default scripts folder as asp to execute aspx files n Microsoft expected developers to switch to aspx… but many asp applications continue to exist, and VB developers continue to develop them, to present day!

Advantages of ASP. NET scripts compared to ASP n Asp. net code: Ø is

Advantages of ASP. NET scripts compared to ASP n Asp. net code: Ø is compiled, not interpreted » v 1 relied on an additional /bin folder for deployed “assemblies” or “controls” containing executable code » v 2 onwards used /app_code folder – latter more flexible; could be referred to directly from a site configuration file Ø uses xml-type tags Ø can be written using a variety of programming languages » language declared at beginning of file Ø is full object-oriented and can easily be used as “controls” to respond to on-screen “events”

Running controls with ASP. NET n Microsoft developed an “intermediate language” (IL) for. net

Running controls with ASP. NET n Microsoft developed an “intermediate language” (IL) for. net framework Ø could be readily converted into machine code but the IL not easily hacked n Source code for. net development can be written in any language that can be translated into IL Ø VB. NET builds on existing practice from asp Ø C# has proved to be most popular with developers, many of whom had previously used “C” and C++ » why use VB. net, when you can use C!?

Components of the evolving. net framework n . net common language infrastructure (CLI) Ø

Components of the evolving. net framework n . net common language infrastructure (CLI) Ø “managed execution” framework for scripts Ø runs Intel x 86 IL code » common Language run-time (CLR) for executing controls » ready to run; development language irrelevant n n Besides /bin folder for “assemblies” & executables, v 1. net framework web applications also must have: Ø a web. config file Ø (store of configuration info e. g. a path to database file) As well as app_data, . net apps from v 2 onwards also support the following additional folders: Ø , app_code, app_browsers, app_themes, app_localresources, app_globalresources, app_webreferences Ø app_code preferred over “bin” for compiled assemblies

How the. net environment manages an application n n “Assemblies” from. aspx files added

How the. net environment manages an application n n “Assemblies” from. aspx files added to /bin CLI executes IL assemblies as CLR (runtime) Ø just a set of Win 32 DLLs created by compiling the assembly components » written in IL » makes sure script execution is “controlled” and kept within boundaries » an earlier version of IIS used to “leak” memory until the system needed rebooting Ø usually loaded implicitly when a. net application is run

Mechanism of Loading Assemblies for processing “App. Domain” sets up a security boundary in

Mechanism of Loading Assemblies for processing “App. Domain” sets up a security boundary in memory for each application n Code (. exe, or. dll) loaded into process “spaceperfo” n JIT compilation ensures “flat out performance” n Øcf Wallace & Grommit – latter lays out the track as the train is about to pass along it

HTTP processing n . net architecture designed “with failure in mind” Ø overall control

HTTP processing n . net architecture designed “with failure in mind” Ø overall control with http. sys Ø if memory usage gets too large, . net pulled down and restarted… n Each App. Domain uses a pipeline of objects to handle requests Ø Httpapplication – oversees flow Ø Httpcontext – tracks “per request” state Ø Modules – generic “pluggable services Ø Handlers – http requests n Covers most (all? ) eventualities and makes sure requests are correctly dealt with – no muddling of threads (!)

Very Useful ASP. net components: 1. Web Controls n Reusable classes used to render

Very Useful ASP. net components: 1. Web Controls n Reusable classes used to render parts of a page ØSimilar to Windows “forms” n New control created for each request » view state/Event tracking handled automatically n A typical web page may have a hierarchical structure of web controls to makes them easily manageable

Very Useful ASP. net components: 2. Event Handlers n HTTP is stateless (no data

Very Useful ASP. net components: 2. Event Handlers n HTTP is stateless (no data retention) Ø no multi-step processes possible Ø e. g. HTML form contents disappear once form submitted n Web Controls provide scope for handling events, when triggered (or raised) Ø e. g. Page_Load, On. Click Ø “Post. Back architecture” Ø allows web forms data to reappear on the screen

Very Useful ASP. net components: 3. Master Pages & Themes n Master Page Ø

Very Useful ASP. net components: 3. Master Pages & Themes n Master Page Ø resides in. master file Ø defines template for other pages » cf powerpoint slide master Ø Contains top <html>, <body>, <form> tags Ø “Page” command utilises master either “static” or “dynamic” Ø “Page_init” process renders components n Themes Ø allow common styles to be applied across a series of pages n Developers can still use. CSS files Ø fully supported by the master file and page “themes” concepts

. net Development and RAD tools n By now, you may be thinking… Ø

. net Development and RAD tools n By now, you may be thinking… Ø “Help! I can’t program in “C”!” n DON’T BE SCARED! Ø the syntax of object-oriented C# is similar to Java Ø RAD tools such as Dreamweaver (earlier versions) and Visual Web Developer provide a range of web controls already written in C# Ø Extension Managers enable other controls to be added to the RAD environment n RAD tools also help with Ø putting controls/assemblies into the /bin or /app_code folder Ø setting up the web. config file

Reading/Writing to data store n The programming language defines the data structure for any

Reading/Writing to data store n The programming language defines the data structure for any data being written to a file n Could be very simple Ø Ø n n e. g. CSV (fields separated by commas) saved as a stream of text flatfile, no relations consequent limited scope for searching and selectively extracting data The VB 6 Practical exercise in the previous session (orderform. html & asp) used such an approach… In practice, relational databases are normally used to store data Ø need proper connectivity software! Ø RAD environments make establishing connectivity with relational databases just as easy with asp. net as it was with asp

Relational Databases n Much more complex than “flat” text files… Ø but a tight

Relational Databases n Much more complex than “flat” text files… Ø but a tight structure means existing data can be more easily located… n n Real advantage of a true relational database is that SQL can be used for r/w & query database operations To make a two-way link, it is just necessary to: Ø make relevant Microsoft data access components (MDAC) available Ø define “recordsets” (asp) or “datasets” (aspx) using a programming language & embedded SQL Ø provide connectivity link to database pathname

Database Design n Same principles apply as with any other relational database management system

Database Design n Same principles apply as with any other relational database management system (RDBMS)… Ø identify entities & attributes Ø produce entity relationship » define logic relationships between entities Ø make sure data is fully normalised » create tables & links Ø use embedded SQL statements in the server script to communicate with the data: » extract data from specific fields in particular tables » put data into specific fields in particular tables n However, some “self-taught” developers will be unaware of this, and try to build the data round the processing…

Evolution of Application - RDBMS connectivity n In the early web development days… Ø

Evolution of Application - RDBMS connectivity n In the early web development days… Ø for the connection of an application to a relational databases… Ø a client application had to be written to use the proprietary API (application program interface) n Even then, there was a problem: Ø what if more than one RDBMS needs to be used? n The solution would be to use several different APIs Ø each needed a client application… Ø added greatly to the complexity of the task!

The Microsoft Solution: the ODBC API n Aspiration: the “Universal Data Access” (UDA) model

The Microsoft Solution: the ODBC API n Aspiration: the “Universal Data Access” (UDA) model Ø all data consumers interact with all data providers… Ø response to the “API for each application” problem n n First stage: ODBC = Open Database Connectivity Developed in early 1990 s: Ø common API for writing applications to access ANY relational DBMS for which an ODBC driver had been written n Once the APIs had all been written, tried, and tested… Ø any relational database with an ODBC compliant interface could use them Ø DSN model offered easy database path connectivity string management

Active. X n The next stage in evolution of Microsoft’s data objects model Ø

Active. X n The next stage in evolution of Microsoft’s data objects model Ø sexy name for OLE v 2. 0 Ø made up of… » OLE n Object Linking and Embedding… » Combined with COM n n Common Object Model Active. X Data Objects make up a series of modular components called ADO Ø used for “run-time” web applications Ø basis of. net controls

More about VB Active. X Data Objects (ADO) n Designed to simplify the writing

More about VB Active. X Data Objects (ADO) n Designed to simplify the writing of client applications to access data sources through OLE DB providers Ø even more flexible than DSN which had to be specified on the local machine and was limited to the ODBC providers on that machine n n use a common, easy-to-use object model data sources can now also include: Ø spreadsheets Ø graphics Ø web pages

OLE DB n Application of OLE/Active. X principles to connectivity between applications and databases

OLE DB n Application of OLE/Active. X principles to connectivity between applications and databases Øto be more precise, and relational database management systems n An interface specification that provides a layer of abstraction between: Øa data provider e. g. relational DBMS Øa data consumer e. g. business object or client application

Universal Data Access in practice

Universal Data Access in practice

System Connection to the Database n Provided by Microsoft Data Access Components (MDAC) Ø

System Connection to the Database n Provided by Microsoft Data Access Components (MDAC) Ø easily downloaded: » www. microsoft. com/data/download_21242023. htm n Once the correct components have been chosen… Ø for scripts on a web server to be able to talk with a relational database, a logical 'connection' needs to be set up on the local system Ø Must include: » a definition of where the database is » a few simple rules on how the database should be treated

Making a connection to a database on the web server n Two systems still

Making a connection to a database on the web server n Two systems still popular: Ø ODBC – “legacy”. asp scripting Ø OLE DB –. aspx connectivity n Whichever is used… Ø essential to get connectivity working correctly » RAD tools very helpful… Ø server-script can then use SQL commands to link to and communicate smoothly with database tables » again… RAD tool can save a lot of time…

Thanks for listening…

Thanks for listening…