Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client:

Similar presentations


Presentation on theme: "1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client:"— Presentation transcript:

1 1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client: user interface database server: stores data. business logic: resides on both Three or multi-tier architecture: Presentation layer: client, browser Business layer: web server, handles web requests and actual functionality Database layer: database server, stores data

2 2 Three-Tier Architecture

3 3 Benefits of Web Applications Standard & thin client: web browser –Easy maintenance both server and client –Easy upgrade both server and client –Fast development Mature technologies and platforms –Security https, password protection, firewall transparent Limitations –Compatibility of different web browsers –Limited functionalities

4 4 Web Technolgies Client-side –HTMLCSS (Cascading Style Sheets) –XML (Extensible Markup Language) –JavaScriptVBScript –FlashJava applet Server-side oPHP PERL / CGI oASP (Active Server Pages) & ASP.NET oJSP (Java Server Pages)Java Servlets oC++/C Database  ODBC, JDBC  MS SQL, Oracle, DB2, my sql…

5 5 Web Application Option1: LAMP LAMP LAMP Linux OS Linux OS Apache Web Server Apache Web Server MySQL Database MySQL Database PHP scripting (Hypertext Preprocessor) PHP scripting (Hypertext Preprocessor) Advantage Advantage Free Free Open source Open source Proved to be one of the most reliable ways for web development Proved to be one of the most reliable ways for web development Disadvantage Disadvantage Tech support Tech support Higher HR cost Higher HR cost

6 6 Web Application Option2: Microsoft Microsoft technologies Microsoft technologies Windows 2003 / vista OS Windows 2003 / vista OS IIS (Internet Information Server) Web Server IIS (Internet Information Server) Web Server SQL Database SQL Database ASP.NET scripting (Active Server Page) ASP.NET scripting (Active Server Page) Advantage Advantage Tech support Tech support Fast development Fast development Lower HR cost Lower HR cost Continuous improvement on reliability and security Continuous improvement on reliability and security Disadvantage Disadvantage Commercial software Commercial software Not open source Not open source Security, reliability and stability Security, reliability and stability

7 7 Web Application Option3: Java Java technologies Java technologies Unix / Linux OS Unix / Linux OS Apache + Tomcat / Websphere / Weblogic Web Server Apache + Tomcat / Websphere / Weblogic Web Server Oracle / Sybase / DB2 / Mysql Database Oracle / Sybase / DB2 / Mysql Database JSP scripting (Java Server Page) and Servelet JSP scripting (Java Server Page) and Servelet Advantage Advantage Proved to be one of the most reliable and secure ways for web development Proved to be one of the most reliable and secure ways for web development Many third party software Many third party software Disadvantage Disadvantage High development cost High development cost High HR cost High HR cost Future unclear Future unclear

8 HTML www.w3schools.com 8

9 9 Forms HTML and forms are used to build front-end application CGI/ASP/PHP/JSP are used to build the back-end application A Form A Text Input Box A Radio Button A Check Box A Hidden Varible A Submit Button

10 10 Apache, MySQL and PHP Integration

11 11 PHP Error Turn on php error reporting: –For development server, very useful; for production server, don’t do that. –php.ini display_errors = On error_reporting = E_ALL & ~E_NOTICE –httpd.conf php_flag display_errors on php_value error_reporting 2039

12 12 PHP Overview Open Source server-side scripting language designed specifically for the web. –Conceived in 1994, now used on +10 million web sites. –Outputs not only HTML but can output XML, images (JPG & PNG), PDF files and even Flash movies all generated on the fly. Can write these files to the file system. –Supports a wide-range of databases (20 + ODBC). –PHP also has support for talking to other services using protocols such as LDAP, IMAP, SNMP, NNTP, POP3, HTTP. Easy learning curveEasy learning curve –Syntax –Syntax Perl- and C-like syntax. Relatively easy to learn. –Large function library –Embedded directly into HTML The separation of HTML design and PHP tagsThe separation of HTML design and PHP tags –Interpreted, no need to compile

13 13 PHP Tags See www.w3schools.com PHP code must be surrounded with special tags Write text to the browser with the echo command To write Hello, World! to the browser, include the following in hello.php <?php echo “ Hello, World ”; ?> Php code can be pretty much anywhere in HTML document.

14 14 PHP Variables Variable –names can be of any length; –can include letters, numbers and underscores; –case-sensitive To assign values to variables: –$foo = ‘bar’; Data Type: String –$foo = 1; Data Type: integer –$foo = 5.34; Data Type: Double –$foo = array(“bar”,”united”); Data Type: Array Data Types are automatically assigned though you can force a data type by type casting. For example: –$foo = ‘Hello’; –$bar = (int)$foo; –$bar now equals 0 Almost all variables are local. Globals include $_POST Array: $names[0] = 'Helen'; $names[1] = 'Susan'; $names[2] = 'Marc';

15 15 PHP Operators Operators –Assignment (e.g. =, +=, *=) –Arithmetic (e.g. +, -, *) –Comparison (e.g., >=, ==) –Logical (e.g. !, &&, ||) Comments –// –/* */ –Good code will use indents and comments. –Useful debugging skill put echo commands in the middle of your code, to observe the output value and debug, then just comment out the echo commands.

16 16 1st PHP script Hello World! <?php echo “ Hello, World ”; ?> <?php $myvar = "Hello World"; echo $myvar; ?> On server, save it as e3.php in $HOME/.WWW-orion/, On client browser, visit http://orion.csl.mtu.edu/~yourid/e3.php

17 17 Control Structures Conditional structures (e.g. if/else) Repetition structures (e.g. while loops). Example if/else if/else statement: if ($foo == 0) { echo ‘The variable foo is equal to 0’; } else if (($foo > 0) && ($foo <= 5)) { echo ‘The variable foo is between 1 and 5’; } else { echo ‘The variable foo is equal to ‘.$foo; }

18 18 PHP - Forms Access to the HTTP POST and GET data is simple in PHP The global variables $_POST[] and $_GET[] contain the request data Save this example as form.php <?php if ($_POST["submit"]) echo " You clicked Submit! "; else if ($_POST["cancel"]) echo " You clicked Cancel! "; ?>

19 19 PHP - Sessions Sessions store their identifier in a cookie in the client’s browser Every page that uses session data must be proceeded by the session_start() function Session variables are then set and retrieved by accessing the global $_SESSION[] Save this example as session.php <?php session_start(); if (!$_SESSION["count"]) $_SESSION["count"] = 0; if ($_GET["count"] == "yes") $_SESSION["count"] = $_SESSION["count"] + 1; echo " ".$_SESSION["count"]." "; ?> Click here to count

20 20 DB select A List of Users Who Have Signed Up For OscarPool <? $dbh = mysql_connect("localhost","root","") or die("Couldn't connect to database."); $db = mysql_select_db(“airline", $dbh) or die("Couldn't select database."); $sql = "SELECT name FROM Employee"; $result = mysql_query($sql, $dbh) or die("SQL statement is wrong."); while ($row = mysql_fetch_array($result)) { $username = $row['username']; $email = $row['email']; echo ' '.$username.' \n'; } mysql_close($dbh); ?> Save it as data.php

21 21 DB update Database update <? $dbh = mysql_connect("localhost","root","") or die("Couldn't connect to database."); $db = mysql_select_db("test", $dbh) or die("Couldn't select database."); $sql = "UPDATE … “ $result = mysql_query($sql, $dbh) or die("SQL statement is wrong."); mysql_close($dbh); echo(“Database updated! ”); ?> Save it as update.php

22 22 Web Project Development How to develop php/asp/jsp web page –Separate the HTML design and php/asp/jsp coding –The artists design the look and feel of the web page –The coders insert php/asp/jsp code into HTML files Several old advises –Use the standard software engineering process to guide web project development –End user interaction and user requirement analysis are important and sometime cumbersome… –Do a small project (a prototype) to test development staff and user reaction. –Separate development platform and production platform –Look for help online and in local community


Download ppt "1 Database Driven Web Application Clients Application Servers including web servers Database Server Traditional client-server (2-tier architecture): client:"

Similar presentations


Ads by Google