Presentation is loading. Please wait.

Presentation is loading. Please wait.

COMP3241 E-Business Technologies Richard Henson University of Worcester October 2012.

Similar presentations


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

1 COMP3241 E-Business Technologies Richard Henson University of Worcester October 2012

2 Week 2 – Early Web Applications, ActiveX controls, and.net n Objectives:  Compare and contrast embedded code for client-only applications & server scripting  Explain how client-side VBScript evolved into run-time ActiveX, which itself evolved into secure server-script  Use a client-server.net development environment for development and testing of.net master pages and code behind

3 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)...

4 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

5 Embedded programming code in HTML Files n n Still.html and executed on the Browser   Browser needs to have interpreter for that programming language e.g. » »VB Script » »Java Script n n For the Browser to call the right interpreter, an appropriate declaration statement needs to be included in the start line

6 Request and responses n n Organisation of application processing across a client-server network… n n Client:   requests services or information from another computer (e.g. the server) n n Server:   responds to the client's request by sending the results of the request back to the client computer

7 Request and responses client requests information server processes the request, sends a response back to the client

8 Internet Communications n Based on principles of client/server networking  EITHER Internet computer can “play” the role of client or the role of server  e.g.(1) A user in one university sends an email to a user in another university: »“A” client sends email to “B” server  (2) When a reply comes back… »“B” client sends email to “A” server

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

10 Writing Server Scripts n n NOT saved as.html! n n Server code can be embedded directly into HTML code…   Command is needed to inform the web server » »(1) that non-HTML code is about to be used » »(2) when next code reverts to HTML n n With.asp scripts… (no longer used)   the command to start the script was <%   to end the script… %> n n With.php scripts…   <?php starts the script  ends the script  ?> ends the script

11 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  how? use “localhost” in the URL at the Browser end (localhost = path to the server scripting root folder) n A typical URL for testing such a script locally could then be (depending on script type):  http://localhost/scriptname.aspx http://localhost/scriptname.aspx  http://localhost/scriptname.php http://localhost/scriptname.php

12 Web Dynamic Client-Server Model (1) Server-Side Processing in a typical web-based client-server application: 1.HTML form on web browser collects data at the client end 2.HTTP enables the form data to be sent to a web server

13 Web Dynamic Client-Server Model (2)  3. web server processes the form data according to instructions on a server script called at the client end  4. output from processing stored temporarily on web server

14 Web Dynamic Client-Server model (3)  5. server script sends output back to browser with HTML code to create a structure to display the data (e.g. HTML table)  6. This gets even more complex when a database, and database programming, are also involved at the server end…

15 Introduction to Server-scripting n The following apply to ALL types of scripting…  real programming code is essential »note: HTML is a FORMATTING language, NOT a programming language  both client and server ends need to have links to programming code: »client end…embedded within a HTML page »server end… could be embedded or separate

16 Languages used for Server Scripting n Much has been tried since HTML became interactive in the early 1990s:  Can use an existing language in a completely separate file, which is already compiled and ready to go: »the original approach:.cgi »any language could in theory be used »in practice “C” was usually favoured  Can use an existing language embedded in a HTML file »The Microsoft.asp approach, using embedded VB source code »The Sun.jsp approach, using embedded Java (Script) source  Can utilise/invent a scripting language that is “HTML-like” and easily embeds with HTML »PERL »Cold Fusion.cf »Preprocessor Hypertext processing.php

17 Microsoft’s first attempt at server scripting… n In 1996, Microsoft introduced active server pages (asp)  hugely successful  soon became more popular than.cgi n However, in spite of the great success of asp, big problems were emerging…  by 2000, hackers were attacking Microsoft servers and finding many security holes in IIS »Microsoft only coped by offering hotfixes  further problem: used VB source code »if server not secure, code could be copied or compromised »Scripts could not be truly “object oriented”

18 ASP becomes ASP.NET n Microsoft’s new approach to server scripting for the new millennium…  building on asp principles  new system that used “intermediate language”, rather than source code on the server  much more difficult to hack n Security problems with VB…  out with the old (asp)  in with the new (asp.net) n New environment known as the.net framework  many developers accustomed to VB/.asp  took awhile to catch on!

19 Development of.NET framework for Server Scripting n n BASIC and VB very much a part of Microsoft’s strategy, until circa 1999/2000…   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 What to replace VB source code with?   applied source VB -> ActiveX run-time principles server-side   Server equivalent of ActiveX controls could now be used/developed n n Result:.net Framework & ASP.NET:   VB evolved into the more object oriented (and complied) VB.NET  .net framework provided the basis for » ».net server-side controls » »the ubiquitous use of compiled languages

20 Advantages of ASP.NET scripts compared to ASP n n Compiled, not interpreted n n Web Controls use xml-type tags n n Can be written using a variety of programming languages   language declared at beginning of file   fully object-oriented and many controls written to respond to on-screen “events”

21 Which Source Code Language? 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   But… 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 a more powerful, compiled, and object-oriented language like C?

22 Components of the evolving.net framework n Common Language Infrastructure (CLI) at the server end (i.e. IIS)  “managed execution” framework for scripts  runs Intel x86 IL code »common Language run-time (CLR) for executing controls »ready to run; development language irrelevant   /app_code folder for deployed “assemblies” or “controls” containing executable code, and databases  web.config file »store of configuration info e.g. a path to database file  from v2 onwards the following additional folders: »app_browsers, app_themes, app_localresources, app_globalresources, app_webreferences

23 How the.net environment manages an application n “Assemblies” from.aspx files added to /App_Code (usually.dll files created by compiling the assembly components) n CLI executes IL assemblies as CLR (runtime)  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

24 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

25 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 (!)

26 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

27 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

28 Very Useful ASP.net components: 3. Master Pages n Master Page  Created as a.master file  defines template for other pages »cf PowerPoint slide master  Contains top,, tags  “Page” command (top of page) utilises master: »either “static” or “dynamic”  “Page_init” process renders components

29 Very Useful ASP.net components: 4. Themes n 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

30 .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 (VWD) provide a range of web controls already written in C#  Extension Managers enable other controls to be added to the RAD environment n VWD also help with general file/folder management such as putting controls/assemblies into the right folder  i.e. /app_code

31 Managing C# Code, HTML code, and web controls n n Each has its own syntax!   earlier versions of.net had all three types together!   More recently “code behind” files encouraged » »Standard HTML & web control file saved as.aspx » »associated C# code saved as a.cs file n n declared through “Page” command

32 Running.aspx,.cs, etc. pages toghether n n All managed within the.net run-time environment   normally at server-end using IIS   Visual Studio allows use of a cut-down version of IIS at client end for testing   developer doesn’t need to do anything more, provided that files all in the right folders…

33 Running controls & C# with ASP.NET n n Semi-compiled into “intermediate language” (MSIL) for.net framework and saved together as an “assembly”   intermediate code executes very quickly when required…

34 Now you try it… \


Download ppt "COMP3241 E-Business Technologies Richard Henson University of Worcester October 2012."

Similar presentations


Ads by Google