COMP3076 E-Commerce Technologies: Richard Henson University of Worcester October 2006
COMP3076 E-Commerce Technologies: Richard Henson University of Worcester October 2006
Objectives:
Describe the server-side scripting model Explain how software tools can assist with integration of the four basic components of a client-server dynamic web pages application Create and use a simple database-linked server-script with Dreamweaver MX
Why bother with server-scripts anyway why not do all the processing on the local browser?:
basic web pages provide the static content data and other files downloaded separately to provide some degree of dynamic content all applications software downloaded to the client and application runs on the client
Downside:
local editing of code possible, which may compromise security
Retrieve a web page via the Internet (web browsing - static content):
use http to send search string to local server local server converts domain name to IP address & uses http to send request to remote server remote server locates the web page and uses http to send it to the local server local server uses http to send the page to the browser browser display page as an exact copy of the original
Until about 1997, MOST client browsers only requested and displayed data Increasing use of VB and JavaScript resulted in quite sophisticated client-end web applications
e.g: e-commerce systems such as shop@ssistant e.g: graphics-intensive gaming systems
Content is dynamic and readily communicable between client and server Typical process
Input screens (e.g. forms) collect information on the client browser & send it to the web server
Exactly the same principles apply as any other client-server applications running on two computers, and communicating data Same comms protocol (HTTP) used:
across a network [Intranet] through a secure outside line [Extranet]
results of processing sent back to client and merged with a static web page to provide the display
Server-side scripting is required for any applications that require a dynamic input to the browser:
usually that will contain code that can extract data from or send data to a database whenever database updated:
updated data picked up by server-script when it runs
updated data displayed on client browser
In an ideal world everything would be able to run via the browser on the client machine:
faster all data local more controlled
If
only small data sources, or infrequently changed data sources are used data wasnt being captured for a database that would be accessible by other clients, this could be the case
Small amount of product data held in a text or csv file Downloaded product data:
either easily integrated into an array within a compact, downloadable chunk of JavaScript functions embedded in a HTML file or easily converted into a client-side script written in JavaScript
e.g. use of a client-side script such as a GDIdb script to access a small downloadable database
Pitfalls:
what if a large, regularly updated centralised data store needs to be accessed?
Example: search engine:
whole database would have to be downloaded every time the application is to be used! client not powerful enough client wouldnt have the storage capacity bandwidth not sufficient local editing of code/data can compromise security
Web Server to communicate with browser Server-script(s) on the web server to process the form & send data to the database Database for the script to interact with and receive/send data from/to Connectivity software to link server-scripts and embedded SQL with the database
Making it easier!
Like other web development tools, Dreamweaver can manage all of these components
great for producing web pages with templates, style sheets, forms, tables, etc. deals with local/remote server, connectivity software, type of script (could be asp, cold fusion or java server pages) many server scripts available, either within Dreamweaver or via the web using Extension Manager
latter also supports more complex server behaviours such as shopping carts
Dreamweaver for
Developing & Managing Dynamic Websites
Individual pages:
can allow development in DHTML (fusion of HTML, style sheets, and JavaScript) dynamic client-side effects known as client behaviours
Local/Remote site
can manage links, features and effects (as site assets) over whole web sites can synchronise pages between pre-defined local site and www-based remote site Additional application server definition added to same remote site, or a further www-based site
As the scope of the www became apparent, Tim Berners-Lee added several features to basic HTML syntax to allow data to be passed to server processes One method added is the GET function tagged on as a parameter to the URL e.g. Get <www address>/thetest.jsp?firstname=richard&pas sword=holidays&lastname=henson&action=t ransferbankfunds
POST
alternative method of sending data designed to be used within HTML forms
Example of syntax:
post /thetest.jsp firstname=richard&password=holiday s&lastname=henson&action=transfer bankfunds
sends HTML info back to the browser to format and display results of processing as it wishes
CGIs: free-standing programs connected to the Web server only through a few invocation parameters and environment variables
each cgi process
takes quite a lot of server memory has to be loaded in and out of memory before/after use
Must run server-side therefore no point downloading code to client Must be of an appropriate type for the web server that is to execute the code Have built-in technologies for:
accessing large databases held on remote web servers anywhere on the world wide web, security restrictions permitting performing many queries per second on such databases
Script/HTML code combined according to clear syntax rules and saved with approp suffix
Pages
Insert
CF and PHP:
both scripting languages both designed to integrate with HTML and database systems CF was designed for Windows NT/IIS platforms PHP originally designed for Linux; now runs on Windows
Features of ASP
Syntax designed to mix plain HTML and script code into a single file
hybrid approach between static content and dynamically created content dynamic portions appear between special ASP markers:
<% at the beginning of a script segment %> at the end of a script segment text outside markers downloaded as it is text inside the ASP markers executed as a script, output of the script code is downloaded
The Database
Whole point of a server-script is usually to query a web based database When planning a new web-based system, it may be that the required database already exists The choices are:
EITHER to convert/port data into a new DBMS OR, assuming the existing database is relational, make use of the existing DBMS as it stands
Access cant support more than 10 concurrent users/queries MySQL falls short of full SQL capability in other ways:
http://www.borland.com/resources/en/p df/white_papers/ib_vs_MySQL.pdf
Still integrate well with server-side scripting However, use a slightly different SQL syntax:
not automatically transferable to enterprise databases if an organisation subsequently need to move up to a more powerful system
Enterprise databases like SQL Server and Oracle give you full-blown programming and business logic within the database
Alternatively, create an Access Project file that uses the SQL Server database engine (e.g. Access XP)
Dreamweaver has an excellent facility to allow database development from within However, it is generally recommended that database code be written in the databases own environment Reasoning: all database logic is encapsulated where it belongs:
i.e. in the database not on an ASP, CF, or PHP page
Field link programming etc. resides within the database rather than on a specific Web page
consequently, when something needs to be changed in the database: simply have to change the Stored Procedure or View not all your UD pages
Previous investment in programming will still remain even if the developer changes platform/scripting language
Using IIS:
All Microsoft components (MDAC) Freely available on the web MDAC enables any database system to link to IIS MDAC more vulnerable to viruses, etc.
Using Apache:
No MDAC vulnerabilities Can still use ODBC if on Windows platform
ASP/IIS/Windows CF/IIS/Windows PHP/Apache/Windows PHP/Apache/Unix Software freely available to support most environments running on Windows For development purposes, Dreamweaver server behaviours for all three server scripting languages
Which to Use?
All have their adherents All can easily go pear shaped! Most reliable:
all Microsoft? no Microsoft!
All Microsoft options means using existing skills rather than learning new ones:
asp programming code - Visual BASIC skills creating a relational database Access a popular platform
SQL
Popularised by:
ORACLE on mid-range systems DB2 on IBM mainframes
It figures that:
the more a developer is competent with SQL syntax the more elaborate interaction they will be able to achieve with database data
Learning SQL?
Have a go! Dreamweaver has ready made server behaviours with SQL queries built-in Possible to practice modifying queries using Dreamweavers SQL query writing tool
gives you experience of server behaviours, databases, and SQL queries all at the same time Will also come in very handy when you come to design that shopping cart system