Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP3121 E-Business Technologies Richard Henson University of Worcester October 2010.

Similar presentations


Presentation on theme: "COMP3121 E-Business Technologies Richard Henson University of Worcester October 2010."— Presentation transcript:

1 COMP3121 E-Business Technologies Richard Henson University of Worcester October 2010

2 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 JavaScript relates to Sun Java, and why JavaScript is the preferred language for many Internet developers  Explain how VBScript can to be used in server- scripting, and why it has fallen out of favour  Set up a software development environment for producing client-server websites with remote database support

3 Client-side: going beyond HTML… n n HTML cannot do everything!   sequence of code…   not a programming language n 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 n Programming languages also deal with:   selection (choice from different code sequences)   iteration (repeating the same code again and again)

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

5 Rapid Generation of Client- side embedded code n 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 n Alternatively, a tool could be used to generate the code at the click of a button:   e.g. Dreamweaver or Visual Studio n 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…

6 Interpreted and Compiled Languages n Programming (source) code must be converted into “machine code” before it can be understood and acted on by the CPU n 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)...

7 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

8 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)

9 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…

10 Day of Enlightenment? n Quote from Sun’s own website:   “… Daily, momentum behind the new vision grew.   WebRunner [early Java application - named after BladeRunner] 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.”

11 Integration of Java and Netscape n Subsequent to WebRunner 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! n Netscape and Sun joined forces n Shares in both companies skyrocketed!

12 JavaScript and JScript n Early 1995:  Sun and Netscape released JavaScript  JavaScript 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 ActiveX 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#

13 History of Visual BASIC n Microsoft’s first success was putting BASIC into a micro as a 32K ROM (1976-7) n “Visual” BASIC evolved in early 1990s  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…

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

15 What is ActiveX? What is ActiveX ® ? 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…

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

17 Writing Server Scripts n 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 n With.asp scripts…   the command to start the script is <%   to end the script… %> n n With.php scripts…   <?php starts the script  ends the script  ?> ends the script

18 Server Scripts and “Localhost” 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 n The secret is to use “localhost” in the URL at the browser window  (localhost = path to the server scripting root folder) n A typical URL for testing such a script (scriptname.aspx) locally could then be: n http://localhost/scriptname.aspx http://localhost/scriptname.aspx

19 Using Software Tools for Client-Server Development n n “localhost” maps directly to the home folder configured on the local web server n n 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…)

20 Development of.NET framework for Server Scripting n 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 n Result:.net Framework & ASP.NET:   VB evolved into the more object oriented (and complied) VB.NET n n Server equivalent of ActiveX controls could now be used/developed for the server end…   basis for » ».net server-side controls » »the ubiquitous use of compiled languages

21 Similarities between ASP and ASP.NET scripts n n Despite fundamental differences between asp and aspx scripts, IIS v5 (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 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!

22 Advantages of ASP.NET scripts compared to ASP n n Asp.net code:   is compiled, not interpreted » »v1 relied on an additional /bin folder for deployed “assemblies” or “controls” containing executable code » »v2 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”

23 Running controls with ASP.NET n n Microsoft developed an “intermediate language” (IL) for.net framework   could be readily converted into machine code but the IL not easily hacked n 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!?

24 Components of the evolving.net framework n.net common language infrastructure (CLI)  “managed execution” framework for scripts  runs Intel x86 IL code »common Language run-time (CLR) for executing controls »ready to run; development language irrelevant n Besides /bin folder for “assemblies” & executables, v1.net framework web applications also must have:  a web.config file  (store of configuration info e.g. a path to database file) n As well as app_data,.net apps from v2 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

25 How the.net environment manages an application n “Assemblies” from.aspx files added to /bin n CLI executes IL assemblies as CLR (runtime)  just a set of Win32 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

26 Mechanism of Loading Assemblies for processing n “AppDomain” 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”  cf Wallace & Grommit – latter lays out the track as the train is about to pass along it

27 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 AppDomain 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 (!)

28 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

29 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, OnClick  “PostBack architecture”  allows web forms data to reappear on the screen

30 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,, 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

31 .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

32 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  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 n The VB6 Practical exercise in the previous session (orderform.html & asp) used such an approach… n 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

33 Relational Databases n 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 n n 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

34 Database Design n 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 n However, some “self-taught” developers will be unaware of this, and try to build the data round the processing…

35 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!

36 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 First stage: ODBC = Open Database Connectivity n Developed in early 1990s:  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

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

38 More about VB ActiveX 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 use a common, easy-to-use object model n data sources can now also include:  spreadsheets  graphics  web pages

39 OLE DB n Application of OLE/ActiveX 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

40 Universal Data Access in practice

41 System Connection to the Database n n Provided by Microsoft Data Access Components (MDAC)   easily downloaded: » »www.microsoft.com/data/download_21242023.htmwww.microsoft.com/data/download_21242023.htm n 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

42 Making a connection to a database on the web server n n Two systems still popular:   ODBC – “legacy”.asp scripting   OLE DB –.aspx connectivity n 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…

43 Thanks for listening…


Download ppt "COMP3121 E-Business Technologies Richard Henson University of Worcester October 2010."

Similar presentations


Ads by Google