COMP 2121 Internet Technology Richard Henson April 2011

  • Slides: 30
Download presentation
COMP 2121 Internet Technology Richard Henson April 2011

COMP 2121 Internet Technology Richard Henson April 2011

Week 10: Running Dynamic Web pages n Objectives – Explain briefly how the. net

Week 10: Running Dynamic Web pages n Objectives – Explain briefly how the. net framework uses programming code running on a web server – Explain what. net controls are, and why they are so useful in server scripting

Advantages of using ASP. NET scripts n Asp. net code: – is compiled, not

Advantages of using ASP. NET scripts 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 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. net framework n Evolving? – now at version v 4.

Components of the evolving. net framework n Evolving? – now at version v 4. 0 n . net common language infrastructure (CLI) – “managed execution” framework for scripts on an IIS web server – runs Intel x 86 IL (Intermediate Language) code » Common Language run-time (CLR) for executing controls » ready to run » development language irrelevant

Components of the evolving. net framework n /App_Data folder for database, web applications also

Components of the evolving. net framework n /App_Data folder for database, web applications also must have a web. config file in the application root folder n As well as app_data folder, . net apps from v 2 onwards also support the following additional folders: – app_code for “assemblies” (compiled code) & executables – app_browsers, app_themes, app_localresources, app_globalresources, app_webreferences…

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 /app_code folder CLI executes IL assemblies as CLR (runtime) – just a set of Win 32 DLLs (dynamic link library files) created by compiling the assembly components » written in IL » makes sure script execution is “controlled” and kept within memory boundaries – loaded implicitly when a. net application is run

Mechanism of Loading Assemblies for processing n n n “App. Domain” sets up a

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

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

HTTP processing n Whole. net architecture designed “with failure in mind” – overall control with http. sys process – if memory usage gets too large… » whole. net framework pulled down and restarted… n Each App. Domain uses a pipeline of objects to handle requests – – n Httpapplication – oversees flow Httpcontext – tracks “per request” state Modules – generic “pluggable services Handlers – http requests 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) – – n no multi-step processes possible e. g. HTML form contents disappear once form submitted 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 Power. Point 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 Don’t be phased by the. net architecture

. net Development and RAD tools n Don’t be phased by the. net architecture and use of a programming language like C… – the syntax of object-oriented C# is similar to Java – RAD tools such as Dreamweaver (earlier versions) and Visual Web Developer make development easy by… » providing a range of web controls already written in C# and ready to compile » helping with putting controls/assemblies into the /app_code folder » setting up the web. config file – many other previously written controls are available on the web

Using Relational Databases n Real advantage of a true relational database is that SQL

Using Relational Databases n 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 n To make a two-way link between database and

Databases and the. net architecture n 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

Microsoft Data Access Components (MDAC) Provide connectivity between the system and a wide range of databases n Easily downloaded: n » www. microsoft. com/data/download_21242023. htm n 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 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 connectivity between Applications & RDBMS n In the early web development days…

Evolution of connectivity between Applications & RDBMS 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 (Application Programming Interfaces) – 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 Active. X Data Objects (ADO) n Designed to simplify the writing of

More about Active. X Data Objects (ADO) n Designed to simplify the writing of client applications to access data sources through OLE DB providers – more flexible than the earlier ODBC model » had to be specified on the local machine » limited to the data providers on that machine n Active X uses 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 relational

OLE DB n Application of OLE/Active. X principles to connectivity between applications and relational database management systems – interface specification 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

Making a connection to a database on the web server Each new version of.

Making a connection to a database on the web server Each new version of. net provides more database controls n RAD tools very helpful at making these accessible… n – server-script can then use SQL commands to link to and communicate smoothly with database tables – can save a lot of time…

How FTP works n Used with TCP/IP to send files from one site (server)

How FTP works n Used with TCP/IP to send files from one site (server) to another (client): – all Internet Servers have unique IP addresses – IP address used by IP protocol to manager transfer of data packets from one site to another – TCP used to arrange packets into the correct order, through listening on port 21 (as opposed to HTTP packets, which use port 80) – data rearranged into correct format for screen presentation by FTP protocol

How FTP works n Server offers FTP as a web service – username/password controlled

How FTP works n Server offers FTP as a web service – username/password controlled access to folders – tends to be associated with a www service Device defined to be accessed through TCP port 21 n FTP service accessed by FTP clients via TCP/IP and the Internet n

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

FTP Servers n n Set up (by default) to listen for FTP requests on TCP port 21 During FTP access: – FTP client tools attempt to log on to the server, and get access to the directory or directories provided by the service – FTP client tool receives/sends selected files from/to appropriate directory on the FTP server – communication channel is terminated

Windows FTP Servers n FTP service provided as a component of: – Internet Information

Windows FTP Servers n FTP service provided as a component of: – Internet Information Server (Microsoft) – Apache web server n Other third party products: – WS FTP server (Ipswitch) – FTP Serv-U

Unix FTP servers NOTE: to avoid upsetting Unix’s file system, filenames should be lower

Unix FTP servers NOTE: to avoid upsetting Unix’s file system, filenames should be lower case and avoid punctuation n Examples: n – ftpd (ftp daemon) – based on original DARPANet specification – Apache web server (originally for Unix)

Thanks for listening…

Thanks for listening…