comp2121 internet technology

30
COMP2121 COMP2121 Internet Technology Internet Technology Richard Henson Richard Henson April 2011 April 2011

Upload: slade-hooper

Post on 02-Jan-2016

25 views

Category:

Documents


0 download

DESCRIPTION

COMP2121 Internet Technology. Richard Henson April 2011. Week 10: Running Dynamic Web pages. Objectives Explain briefly how the .net framework uses programming code running on a web server Explain what .net controls controls are, and why they are so useful in server scripting. - PowerPoint PPT Presentation

TRANSCRIPT

COMP2121COMP2121Internet TechnologyInternet Technology

Richard HensonRichard Henson

April 2011April 2011

Week 10: Running Dynamic Week 10: Running Dynamic Web pagesWeb pages

ObjectivesObjectives– Explain briefly how the .net framework Explain briefly how the .net framework

uses programming code running on a web uses programming code running on a web serverserver

– Explain what .net controls controls are, and Explain what .net controls controls are, and why they are so useful in server scripting why they are so useful in server scripting

Advantages of using ASP.NET scripts

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”

Running controls with ASP.NET

Microsoft developed an “intermediate language” (IL) for .net framework– could be readily converted into machine code

but the IL not easily hacked Source code for .net development can be

written in any language that can be translated into IL– VB.NET built 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 Components of the evolving .net framework.net framework

Evolving?Evolving?– now at version v4.0now at version v4.0

.net common language infrastructure (CLI).net common language infrastructure (CLI)– ““managed execution” framework for scripts on an managed execution” framework for scripts on an

IIS web serverIIS web server– runs Intel x86 IL (Intermediate Language) coderuns Intel x86 IL (Intermediate Language) code

» Common Language run-time (CLR) for executing Common Language run-time (CLR) for executing controlscontrols

» ready to runready to run» development language irrelevantdevelopment language irrelevant

Components of the evolving Components of the evolving .net framework.net framework

/App_Data folder for database, web /App_Data folder for database, web applications also must have a applications also must have a web.configweb.config file file in the application root folderin the application root folder

As well as app_data folder, .net apps from v2 As well as app_data folder, .net apps from v2 onwards also support the following additional folders:onwards also support the following additional folders:– app_code forapp_code for “assemblies” (compiled code) & “assemblies” (compiled code) &

executablesexecutables– app_browsers, app_themes, app_localresources, app_browsers, app_themes, app_localresources,

app_globalresources, app_webreferences…app_globalresources, app_webreferences…

How the .net environment How the .net environment manages an applicationmanages an application

““Assemblies” from .aspx files added to Assemblies” from .aspx files added to /app_code folder/app_code folder

CLI executes IL assemblies as CLR (runtime)CLI executes IL assemblies as CLR (runtime)– just a set of Win32 DLLs (dynamic link library files) just a set of Win32 DLLs (dynamic link library files)

created by compiling the assembly componentscreated by compiling the assembly components» written in IL written in IL » makes sure script execution is “controlled” and kept makes sure script execution is “controlled” and kept

within memory boundarieswithin memory boundaries

– loaded implicitly when a .net application is runloaded implicitly when a .net application is run

Mechanism of Loading Mechanism of Loading Assemblies for processingAssemblies for processing

““AppDomain” sets up a security boundary in AppDomain” sets up a security boundary in memory for each applicationmemory for each application

Code (.exe, or .dll) loaded into process Code (.exe, or .dll) loaded into process “spaceperfo”“spaceperfo”

JIT (Just in Time) compilation ensures “flat JIT (Just in Time) compilation ensures “flat out performance” of the application…out performance” of the application…– cf Wallace & Grommit – latter lays out the track as cf Wallace & Grommit – latter lays out the track as

the train is about to pass along itthe train is about to pass along it

HTTP processingHTTP processing Whole .net architecture designed “with failure in Whole .net architecture designed “with failure in

mind”mind”– overall control with http.sys processoverall control with http.sys process– if memory usage gets too large…if memory usage gets too large…

» whole .net framework pulled down and restarted…whole .net framework pulled down and restarted…

Each AppDomain uses a pipeline of objects to Each AppDomain uses a pipeline of objects to handle requestshandle requests– Httpapplication – oversees flowHttpapplication – oversees flow– Httpcontext – tracks “per request” stateHttpcontext – tracks “per request” state– Modules – generic “pluggable servicesModules – generic “pluggable services– Handlers – http requestsHandlers – http requests

Covers most (all?) eventualities and makes sure Covers most (all?) eventualities and makes sure requests are correctly dealt with – no muddling of requests are correctly dealt with – no muddling of threads (!)threads (!)

Very Useful ASP.net components: Very Useful ASP.net components:

1. Web Controls1. Web Controls Reusable classes used to render parts Reusable classes used to render parts

of a pageof a page– Similar to Windows “forms”Similar to Windows “forms”

New control created for each requestNew control created for each request» view state/Event tracking handled automaticallyview state/Event tracking handled automatically

A typical web page may have a A typical web page may have a hierarchical structure of web controls to hierarchical structure of web controls to makes them easily manageablemakes them easily manageable

Very Useful ASP.net components: Very Useful ASP.net components:

2. Event Handlers2. Event Handlers HTTP is stateless (no data retention)HTTP is stateless (no data retention)

– no multi-step processes possibleno multi-step processes possible– e.g. HTML form contents disappear once form e.g. HTML form contents disappear once form

submittedsubmitted Web Controls provide scope for handling Web Controls provide scope for handling

events, when triggered (or raised)events, when triggered (or raised)– e.g. Page_Load, OnClicke.g. Page_Load, OnClick– ““PostBack architecture”PostBack architecture”– allows web forms data to reappear on the screen allows web forms data to reappear on the screen

Very Useful ASP.net components: Very Useful ASP.net components:

3. Master Pages & Themes3. Master Pages & Themes Master PageMaster Page

– resides in .master fileresides in .master file– defines template for other pagesdefines template for other pages

» cf PowerPoint slide mastercf PowerPoint slide master

– Contains top <html>, <body>, <form> tagsContains top <html>, <body>, <form> tags– ““Page” command utilises master either “static” or “dynamic”Page” command utilises master either “static” or “dynamic”– ““Page_init” process renders componentsPage_init” process renders components

ThemesThemes– allow common styles to be applied across a series of pagesallow common styles to be applied across a series of pages

Developers can still use .CSS filesDevelopers can still use .CSS files– fully supported by the master file and page “themes” fully supported by the master file and page “themes”

conceptsconcepts

.net Development and RAD tools.net Development and RAD tools

Don’t be phased by the .net architecture and Don’t be phased by the .net architecture and use of a programming language like C…use of a programming language like C…– the syntax of object-oriented C# is similar to Javathe syntax of object-oriented C# is similar to Java– RAD tools such as Dreamweaver (earlier versions) RAD tools such as Dreamweaver (earlier versions)

and Visual Web Developer make development and Visual Web Developer make development easy by…easy by…

» providing a range of web controls already written in C# providing a range of web controls already written in C# and ready to compileand ready to compile

» helping with putting controls/assemblies into the helping with putting controls/assemblies into the /app_code folder/app_code folder

» setting up the web.config filesetting up the web.config file– many other previously written controls are many other previously written controls are

available on the webavailable on the web

Using Relational Databases

Real advantage of a true relational database is that SQL can be used for r/w & query database operations– so .net work with database involves AQL

queries as well– As before, the RAD environment can use

wizards to write the queries for you…

Databases and the .net architecture

To make a two-way link between database and server scripts, it is just necessary to:– make relevant Microsoft data access components

(MDAC) available … – define “datasets” (aspx) for the database using a

programming language & embedded SQL– provide connectivity link to the database using the

appropriate web control

Microsoft Data Access Components (MDAC)

Provide connectivity between the system and a wide range of databases

Easily downloaded:» www.microsoft.com/data/download_21242023.htm

Just because a database type doesn’t seem to be represented, doesn’t mean that it can’t be… MDAC is regularly updated

Database Design 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

However, some “self-taught” developers will be unaware of this, and try to build the data round the processing…

Evolution of connectivity Evolution of connectivity between Applications & RDBMSbetween Applications & RDBMS In the early web development days…In the early web development days…

– for the connection of an application to a relational for the connection of an application to a relational databases…databases…

– a client application had to be written to use the a client application had to be written to use the proprietary API (application program interface)proprietary API (application program interface)

Even then, there was a problem:Even then, there was a problem:– what if more than one RDBMS needs to be used?what if more than one RDBMS needs to be used?

The solution would be to use several different The solution would be to use several different APIs (Application Programming Interfaces)APIs (Application Programming Interfaces)– each needed a client application…each needed a client application…– added greatly to the complexity of the task!added greatly to the complexity of the task!

The Microsoft Solution:The Microsoft Solution:the ODBC APIthe ODBC API

Aspiration: the “Universal Data Access” (UDA) modelAspiration: the “Universal Data Access” (UDA) model– all data consumers interact with all data providers…all data consumers interact with all data providers…– response to the “API for each application” problemresponse to the “API for each application” problem

First stage: ODBC = Open Database ConnectivityFirst stage: ODBC = Open Database Connectivity Developed in early 1990s:Developed in early 1990s:

– common API for writing applications to access ANY common API for writing applications to access ANY relational DBMS for which an ODBC driver had been writtenrelational DBMS for which an ODBC driver had been written

Once the APIs had all been written, tried, and Once the APIs had all been written, tried, and tested…tested…– any relational database with an ODBC compliant interface any relational database with an ODBC compliant interface

could use themcould use them– DSN model offered easy database path connectivity string DSN model offered easy database path connectivity string

managementmanagement

ActiveXActiveX The next stage in evolution of Microsoft’s The next stage in evolution of Microsoft’s

data objects modeldata objects model– sexy name for OLE v2.0sexy name for OLE v2.0– made up of…made up of…

» OLEOLE Object Linking and Embedding…Object Linking and Embedding…

» Combined with COMCombined with COM Common Object ModelCommon Object Model

ActiveX Data Objects make up a series of ActiveX Data Objects make up a series of modular components called ADOmodular components called ADO– used for “run-time” web applicationsused for “run-time” web applications– basis of .net controlsbasis of .net controls

More about ActiveX More about ActiveX Data Objects (ADO)Data Objects (ADO)

Designed Designed tto simplify o simplify the the writing writing of of client client applications to access data sources applications to access data sources through OLE DB providersthrough OLE DB providers– more flexible than the earlier ODBC modelmore flexible than the earlier ODBC model

» had to be specified on the local machinehad to be specified on the local machine» limited to the data providers on that machinelimited to the data providers on that machine

Active X uses a common, easy-to-use Active X uses a common, easy-to-use object modelobject model– data sources can now also include:data sources can now also include:

» spreadsheetsspreadsheets» graphicsgraphics» web pagesweb pages

OLE DBOLE DB

Application of OLE/ActiveX principles to Application of OLE/ActiveX principles to connectivity between applications and connectivity between applications and relational database management relational database management systemssystems– interface specification provides a layer of interface specification provides a layer of

abstraction between:abstraction between:» a data provider e.g. relational DBMSa data provider e.g. relational DBMS» a data consumer e.g. business object or client a data consumer e.g. business object or client

applicationapplication

Universal Data Access in practiceUniversal Data Access in practice

Making a connection to a database on the web server

Each new version of .net provides more database controls

RAD tools very helpful at making these accessible…– server-script can then use SQL commands

to link to and communicate smoothly with database tables

– can save a lot of time…

How FTP worksHow FTP works Used with TCP/IP to send files from one site Used with TCP/IP to send files from one site

(server) to another (client):(server) to another (client):– all Internet Servers have unique IP addressesall Internet Servers have unique IP addresses– IP address used by IP protocol to manager IP address used by IP protocol to manager

transfer of data packets from one site to anothertransfer of data packets from one site to another– TCP used to arrange packets into the correct TCP used to arrange packets into the correct

order, through listening on port 21 (as opposed to order, through listening on port 21 (as opposed to HTTP packets, which use port 80)HTTP packets, which use port 80)

– data rearranged into correct format for screen data rearranged into correct format for screen presentation by FTP protocolpresentation by FTP protocol

How FTP worksHow FTP works SServer offers FTP as a web serviceerver offers FTP as a web service

– username/password controlled access username/password controlled access to to foldersfolders

– tends to be associated with a www servicetends to be associated with a www service Device defined to be accessed through Device defined to be accessed through

TCP port 21TCP port 21 FTP service accessed by FTP clients FTP service accessed by FTP clients

via TCP/IP and the Internetvia TCP/IP and the Internet

FTP ServersFTP Servers Set up (by default) to listen for FTP requests Set up (by default) to listen for FTP requests

on TCP port 21on TCP port 21 During FTP access:During FTP access:

– FTP client tools attempt to log on to the server, FTP client tools attempt to log on to the server, and get access to the directory or directories and get access to the directory or directories provided by the serviceprovided by the service

– FTP client tool receives/sends selected files FTP client tool receives/sends selected files from/to appropriate directory on the FTP serverfrom/to appropriate directory on the FTP server

– communication channel is terminatedcommunication channel is terminated

Windows FTP ServersWindows FTP Servers

FTP service provided as a component FTP service provided as a component ofof::– Internet Information Server (Microsoft)Internet Information Server (Microsoft)– Apache web serverApache web server

Other third party products:Other third party products:– WS FTP server (Ipswitch)WS FTP server (Ipswitch)– FTP Serv-UFTP Serv-U

Unix FTP serversUnix FTP servers

NOTE: to avoid upsetting Unix’s file NOTE: to avoid upsetting Unix’s file system,system, filenames should be lower case filenames should be lower case and avoid punctuationand avoid punctuation

Examples:Examples:– ftpd (ftp daemoftpd (ftp daemon) n) – based on original – based on original

DARPANet specificationDARPANet specification– Apache web server (originally for Unix)

Thanks for listening…