Title: Other Web Application Development Technologies
1Other Web Application Development Technologies
2PHP
3PHP
- Personal Home Pages or PHP Hypertext
Preprocessor - language for creating HTML content
- normally runs as a server-side scripting language
- command line scripting possible
- client-side GUI applications using PHP-GTK
- generates other formats
- PDF, GIF, JPEG, PNG, Flash
4PHP
- free, open source technology
- extensive libraries of PHP code modules
- runs on all major operating systems
- runs with all major web servers (Apache, IIS,
iPlanet) - good database integration
- MySQL, Oracle, ODBC databases, PostgreSQL, Sybase
5PHP example
- ltHTMLgt
-
- ltBODYgt
- ltH1gtPHP Hello World Examplelt/H1gt
- lt?php echo Hello world! ?gt
- lt/BODYgt
- lt/HTMLgt
6PHP architecture
7PHP/Web Server Architecture
- web server layer
- handles http requests
- passes data to PHP via SAPI
- TSRM Thread-Safe Resource Management
- PHP language core
- PHP API (available to core and PHP extensions)
- Zend parsing engine
- runtime compiler
- executer
8PHP/Web Server Architecture
web server (Apache, IIS, etc..)
Server Abstraction API (SAPI)
PHP Core
PHP API
PHP extensions
TSRM
TSRM
Zend Engine
9PHP and http
http request
PHP page
data
client
PHP Zend parsing engine
web server
input
output
http response
HTML
HTML page
10form processing example
lthtmlgtltheadgtlttitlegtIce Cream Parlour
lt/titlegtlt/headgtltbodygt lth1gtIce Cream
Parlourlt/h1gt ltform action ices.php method
POSTgt Flavour ltselect nameflavourgt ltopti
ongtvanillalt/optiongt ltoptiongtchocolatelt/optiongt
lt/selectgt Scoops ltinput type text name
scoops /gt lt/formgt lt/bodygtlt/htmlgt
11form processing example
lthtmlgt ltheadgtlttitlegtIce Cream Responselt/titlegtlt/he
adgt ltbodygt lth1gtThank you for your
orderlt/h1gt lt?php flavour _POST flavour
scoops _POST scoops echo scoops
scoops of flavour coming right
up! ?gt lt/bodygtlt/htmlgt
12- ltHTMLgtltheadgt
- lttitlegtself processing PHP pagelt/titlegt
- lt/headgtltBODYgt
- lt?php if(!empty(_POSTname))
- echo Greetings, _POSTname
- else ?gt
- ltFORM ACTIONlt?php PHP_SELF ?gt
- METHODPOSTgt
- Enter your Name
- ltINPUT TYPETEXT NAMEnamegt
- ltINPUT TYPESUBMITgt
- lt/FORMgt
- lt?php ?gt lt/BODYgtlt/HTMLgt
13control of http response
- PHP sets standard headers by default
- response status line
- date, document length
- other headers added by web server
- header () function allows other headers to be set
- header (content-type text/plain)
- header must be used before any html generated
(including leading lthtmlgt tag)
14cookies
- _COOKIE array used for input
- setcookie () function sets cookie headers in the
http response - lt?php
- accesses _COOKIE accesses
- setcookie (accesses, accesses)
- ?gt
- must be used before html content
15sessions
- PHP provides automatic session handling
- sessions set up using start_session() command
- PHP uses cookies to pass session information
- will switch to URL-rewriting if cookies disabled
- start_session() must appear at the start of the
PHP document
16simple hit counter
lt?php session_start () /a unique session id
will be generated and stored in a cookie named
PHPSESSID / session_register (hits)
/sessions can load in variables registered in an
associative array called HTTP_SESSION_VARS/
hits //variable is incremented ?gt lthtmlgt
etc ltpgtThis page has been viewed lt? hits ?gt
times.
17PHP and XML
18PHP and XML
- PHP has strong text processing functionality
- comprehensive string manipulation
- strong regular expressions
- inherited or imported from Perl
- full set of filehandling functions for file I/O
- XML data files can be created/manipulated
programmatically using text processing approaches
19PHP and XML
- DOM
- DOM processing from PHP 4.3
- DOM extension part of PHP 5 core
- XSLT
- libxslt extension in PHP 5
- A separate XSLT extension available from
Sablotron C library (different API)
20PHP and XSLT
- lt!-- sablotron version --gt
- lt?php
- processor xslt_create ()
- result
- xslt_process(processor,source.xml,transform
.xml) - if(!result) echo xslt_error (processor)
- xslt_free (processor)
- echo ltpregtresultlt/pregt
- ?gt
21events-based XML programming
- PHP has an event-based XML parser
- based on libxml2 library
- SAX parser
- replaces old non-SAX Expat library
- parser calls handler functions as events occur
- you write the event handler functions
22PHP strengths and weaknesses
23PHP strengths
- free, open-source product
- flexible
- extensible
- easy to implement
- builds onto most browsers on most platforms
- familiar, flexible and powerful syntax
- with occasional weirdness thrown in
- good database connectivity
- technology of choice for low-end web-DB system
24PHP weaknesses
- XML support
- some non-standard features still in PHP5
- slow because of runtime compilation then
execution - derives from CGI script origins
- limited separation of coding from HTML
- no equivalent of JSP custom tags
- some open source versions emerging
- see http//trac.php-tools.net/
- extensibility limited by cumbersome C-based
architecture - this is improving with later versions
25PHP web application frameworks
- Frameworks are now emerging for PHP
- Cake
- Next lecture
- growing developer community, growing
functionality - http//www.cakephp.org/
- Symfony
- Very recent but stems from older projects
- established development community
- http//www.symfony-project.com/
- Zend Framework
- growing community of developers
- http//framework.zend.com/
26PHP web application frameworks
- Typical functionality
- CRUD (database interaction)
- M-V-C architecture
- Access control lists
- View helpers - AJAX, JavaScript, etc
- Standard application components
27Active Server Pages (ASP)
- Microsoft-based server-side processing technology
- ASP provides a server-side scripting environment.
- This includes
- Read information from an HTTP request.
- Customize an HTTP response.
- Interact with Databases.
- Support complex middleware.
28Active Server Pages (ASP)
- are processed in response to a client request
- ------ server-side scripting
- are processed by an ActiveX component
- ------ a scripting engine
- have the file extension .asp
- contain HTML tags and scripting code
- VBScript is the most widely used language
- (although you can use JavaScript, other .NET
languages)
29The ASP Architecture
ASP.DLL
30- A user makes an http request for an ASP page.
- The .asp extension tells the Web server that the
page contains server script (executable code)
that it should process before returning the page
to the browser. - The server passes the ASP to the scripting engine
- The scripting engine executes ASP commands as it
encounters them - After execution of the server scripts, all code
is stripped out of the page. - The pure HTML page is sent in the http response.
31A Simple ASP Example
- lt _at_LANGUAGE VBScript gt
- lt Option Explicit gt
- lt!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0
Transitional//EN"gt - lt ' File clock.asp gt
- ltHTMLgt
- ltHEADgt
- ltTITLEgtA Simple ASP Examplelt/TITLEgt
- ltMETA HTTP-EQUIV "REFRESH" CONTENT "60
URLCLOCK.ASP"gt - lt/HEADgt
32A Simple ASP Example
- ltBODYgt
- ltH1gtSimple ASP Examplelt/H1gt
- ltTABLE BORDER "6"gt
- ltTRgt
- ltTDgtlt Time() gtlt/TDgt
- lt/TRgt
- lt/TABLEgt
- lt/BODYgt
- lt/HTMLgt
33(No Transcript)
34ASP Built-in Objects
- Request
- Response
- Session
- Application
- Server
- ObjectContext
35ASP Built-in Objects
- Request
- Retrieves the values that the browser passes to
the server during an HTTP request. - Response
- Controls what information is sent to a browser in
the HTTP response message.
36ASP Built-in Objects
- Session
- Used to manage and store information about a
particular user session. - Application
- Used to manage and store information about the
Web application.
37ASP Built-in Objects
- Server
- Provides access to resources that reside on a
server. - ObjectContext
- Used to commit or abort a transaction managed by
Microsoft Transaction Server (MTS) for ASP pages
that run in a transaction.
38Request Object Collections
- ClientCertificate
- Cookies
- Form
- QueryString
- ServerVariables
39Form Collection
- The Form collection contains the values of each
standard HTML control that has a NAME attribute.
When a user submits a form with the POST method,
you can read the values of the controls by using
the Form collection. - The Form collection of the Request object can be
used to extract information from the body of an
HTTP request message.
40Form Collection
- ltFORM ACTIONicecream.asp" METHODPOSTgt
- Name ltINPUT TYPETEXT NAME"name"gtltPgt
- Favourite Flavour
- ltSELECT MULTIPLE NAMEflavour"gt
- ltOPTIONgtMint
- ltOPTIONgtVanilla
- ltOPTIONgtCoffee
- lt/SELECTgtltPgt
- ltINPUT TYPESUBMIT NAMEiceSubmit"
VALUE"Submit"gt - lt/FORMgt
41Form Collectionicecream.asp
- Request.Form("name")
- Request.Form("flavour")
- or
- lt For Each Item in Request.Form
- 'code to display Item here
- Next gt
42ASP on Alternative Platforms
- Chili!ASP by Chili!Soft (Expensive to buy!)
- Windows
- IIS, Apache, Netscape Enterprise FastTrack,
OReilly WebSite Pro - Solaris
- Apache, Netscape Enterprise FastTrack
- Linux Apache
- IBM AIX Apache, Netscape Enterprise FastTrack,
IBM HTTP Server, Lotus Domino Go - HP UX
- Apache, Netscape Enterprise
43ASP on Alternative Platforms
- Instant ASP (iASP) by Halcyon Software
- cheaper
- written in Java as a Servelet, so runs with
Apache/Tomcat and many other servers - allows mix of ASP and JSP
- better range of functionality
- may run slow for high volume applications
44ASP Strengths
- implements M-V-C
- code embedded in the HTML
- separation of concerns
- no compiling - stays resident in memory
- no complex interfacing - method calls
- suitable for high-end web applications
- standard components
- re-use
- eases programming effort
45ASP weaknesses
- difficult to port between platforms
- steep learning curve for full functionality
- less suitable for low-end web apps
- multiplicity of .NET languages
- diffuse coding options
- can leave legacy problems
46ColdFusion
47ColdFusion
- Technology for building dynamic web applications
- provides powerful markup reducing need for
programming skills - designed for RAD abstracts many low-level tasks
e.g. connection to a database
48ColdFusion
- runs on all major platforms
- compatible with all major browsers
- runs in CGI mode or as an embedded process
- runs on Apache, IIS, iPlanet
- ColdFusion applications are portable across
platforms with very minor differences
49History of ColdFusion
- developed by Allaire software
- first version 1995 - only 30 language elements
- strongly tag-based, supplemented by functions
- Allaire merged with Macromedia in 2001
- MacroMedia ColdFusion
- ColdFusion MX
- ColdFusion MX 6.1 (2004)
- 80 tags, 255 functions
50use and availability
- Widely used for medium to large scale web apps
- Large developer community
- Not free, not open source
- ColdFusion MX Standard 929
- Windows, Linux
- ColdFusion MX Enterprise 4289
- Windows, Linux, Solaris, HP-UX, AIX
- 30-day free trial version (limited functionality)
51ColdFusion Basics
52ColdFusion Markup Language
- tag-based language (CFML)
- mixed with HTML, JavaScript/VBScript in a
template - CFML used to dynamically construct content
- CFML processed by ColdFusion Application Server
on the server side
53CFML template
entity
input
http request
data
client
ColdFusion Application Server
web server
entity
entity
output
http response
HTML
HTML page
54ColdFusion templates
- CFML tags embedded in HTML
- Can produce pure CFML pages
- Tag Syntax
- ltCFTagname ... attributes ...gt content
lt/CTTagNamegt - or ltCFTagname ... attributes .../gt
- trailing / optional
- Attributes are literals or expressions
- Tags controlled by attributes and/or content
55Example 1
lt!--- simple output of variable values
---gt lth2gtWriting outputlt/h2gt ltCFSET xy x y
/gt ltCFOUTPUTgt x xltbr/gt y yltbr/gt x
y xyltbr/gt lt/CFOUTPUTgt
56Example 2
- ltHTMLgtltheadgtlttitlegtlt/titlegtlt/headgt
- ltBODYgt
- ltCFOUTPUTgt
- ltH2gtTodays date is
- DateFormat (Now (),dd/mm/yy)
- lt/H2gt
- lt/CFOUTPUTgt
- lt/BODYgt
- lt/HTMLgt
CFML tag
closing CFML tag
57Example 3
ltCFMAIL FROM "jm_at_comp.rgu.ac.uk" TO
"honsISD_at_comp.rgu.ac.uk" SUBJECT "Assessed
Lab" SERVER "mailhost_at_comp.rgu.ac.uk" gt Have
a Merry Christmas. lt/CFMAILgt
58ColdFusion Web Application Framework
59web application
- a group of templates forming a cohesive
application - maintain state
- utilise constants
- multi-threading
- error and exception handling
- security
- controlled through application template
60Application.cfm template
- reserved template name
- template placed in root directory of the web
application - executed before every request
- may be supplemented by OnRequestEnd.cfm template
- executed after every web request
61processing Application templates
- ColdFusion template requested
- ColdFusion searches template directory for an
Application.cfm template - ColdFusion processes Application.cfm template
then requested template - OnRequestEnd.cfm template processed if it exists
62template request process
Server
application template
client
request
myTemplate
response
onREquestEnd
63function of Application.cfm
- maintains state
- create Application, Client and Session variables
- set application constants
- data-source names, source directories, style
elements - handle errors
- provide security services
- user authentication
- entitlements
64ColdFusionstrengths and weaknesses
65strengths
- tag-oriented programming for web developers
- good support for custom tags and extensions
- full functionality to support medium to high end
web systems - supports MVC
- strong support for thread-safe transactions
- excellent database connectivity
- implemented on all major platforms
66weaknesses
- expensive compared with other technologies
- not open source
- highly redundant syntax
- leads to inconsistent development
- idiosyncratic language structure
- limited code re-use on or from other platforms
- non-standard and limited XML support