Web Engineering (CC 552) Introduction Dr. Mohamed Magdy mohamedmagdy@gmail.com Room 405 (CCIT)
Course Goals n A general understanding of the fundamentals of the Internet programming n Knowledge and experience with the major web technologies and techniques for developing Web-based applications n Develop a working knowledge of HTML, CSS, JavaScript, and PHP as languages for developing Web applications n Insight into what constitutes a well designed, usable web application n Presenting an introduction to XML
Text Book Robert W. Sebesta, Programming the World Wide Web, 6 th edition, Pearson Addison Wesley, 2012
Course Contents Lectures 1 Topic Introduction to Internet Infrastructure and Internet Programming 1 XHTML 1 Cascading Style Sheets (CSS) 1 HTML 5 & CSS3 2 JavaScript + DHTML 4 PHP + MySQL +Sessions 1 AJAX 1 XML 1 AJAX & JSON Objects 1 JQuery
The Internet and the WWW n The WWW is one of the services running over the Internet n Before the WWW The Internet was used by scientists, researchers, large (usually governmental) organizations, and amateur enthusiasts Commerce on the Internet was almost unknown n The WWW is now the major conduct to the Internet and the major vehicle for e-commerce
The WWW n Allows a user anywhere on the Internet to search for and retrieve documents n 1989 WWW proposal by group led by Tim Berners-Lee at CERN n Late 1990 prototype implemented n 1991 WWW released to the rest of the world
Basic WWW Systems Retrieving web pages using HTTP protocol Web Client Browser Web Server (e.g. Apache, IIS) Hosting web pages Internet Web Authoring System create web pages Publish web pages Scanner Video capture Sound card Web page: document written in XHTML, JavaScript, PHP, ASP
Web Programmer s Toolbox n HTML n CSS n JavaScript n PHP
HTML n Describes the general form and layout of documents n An HTML document is a mix of content and controls Controls are tags and their attributes Tags often delimit content and specify something about how the content should be arranged in the document Attributes provide additional information about the content of a tag
Tools for creating HTML documents n HTML editors make document creation easier Shortcuts to typing tag names, spell-checker, etc. n WYSIWYG HTML editors Need not know HTML to create HTML documents
CSS n A language for defining style sheets that was developed for HTML n Provide the means to control and change presentation of HTML documents n Style sheets allow you to impose a standard style on a whole document, or even a whole collection of documents
JavaScript n A client-side HTML-embedded scripting language n Only related to Java through syntax n Dynamically typed and not object-oriented n Provides a way to access elements of HTML documents and dynamically change them
Ajax n Asynchronous JavaScript + XML No new technologies or languages n Much faster for Web applications that have extensive user/server interactions n Uses asynchronous requests to the server n Requests and receives small parts of documents, resulting in much faster responses
PHP n An open source server-side scripting language n PHP code is embedded in XHTML documents n Similar to JavaScript n Great for form processing and database access through the Web n The most widely used
Server-side vs. Client-side Programming n In Server-side, instead of downloading the program and executing on the client, have the client make a request execute the program on the server download the results to the client
Server-side vs. Client-side Programming n Advantages of Server-side programming cross-platform support: browser variations yield differences with JavaScript. With serverside, only have to test & optimize program for server platform more options for applications: server-side program not limited for security reasons, can access files & databases increased power: server machines tend to be more powerful, better tools code integrity: do not have to give client access to source code or data in order to execute
World Wide Web HTTP Server HTTP Client HTML data Software on Server
World Wide Web HTTP Server HTTP Client HTML data Software on Server Database
Purpose of Server-Side Scripting n search engines must maintain a large database of links & documents must be able to index, sort data, perform complex searches requires lots of storage, optimum performance
Purpose of Server-Side Scripting n database access Web page can serve as front-end to a database make requests from browser, passed on to Web server, calls a program to access the database, sends the results back to the browser
Purpose of Server-Side Scripting n Chat and bulletin board services user enters messages in a Web interface, passed on to server chat: a program distributes messages to all connected users bulletin board: a program adds to accessible database of messages
Purpose of Server-Side Scripting n Other applications such as User registration/administration/profiles Transactions E-commerce Social Networks Services
Major Server-Side Technologies n Major Server-Side Technologies Server-Side Includes CGI Perl Java Servlets ASP.NET PHP (Embedded Scripts)
Internet Infrastructure
When Computers Communicate n When two or more computers communicate, they must have a common way in which to communicate. n To do this computers use protocols n A protocol is an agreement by which two or more computers can communicate. n Transfer Control Protocol/Internet Protocol (TCP/IP) is the underlying protocol for the Internet. n The WWW protocol is HTTP.
How TCP/IP Works 1) Transfer Control Protocol (TCP) breaks data into small pieces of no bigger than 1500 characters each. These pieces are called packets. 101010101 001101010 011010011 101010101001 101010011010 011010210101 010101011010 111101010111 011101110110 110000101110 110101010101 001110101001 010111101000 101010101 001101010 011010011 101010101 001101010 011010011
How TCP/IP Works 2) Each packet is inserted into different Internet Protocol (IP) envelopes. Each contains the address of the intended recipient and has the exact same header as all other envelopes. 101010101 001101010 011010011 101010101 001101010 011010011 101010101 001101010 011010011
IP Packet Format (v4) Header Field length in bits Bit 0 Bit 31 Version (4) Hdr Len (4) Time to Live (8) TOS (8) Total Length in bytes (16) Identification (16 bits) Flags (3) Fragment Offset (13) Protocol (8) Source IP Address (32) Destination IP Address (32) Header Checksum (16) Options (if any) Data Data (variable length)
How TCP/IP Works n A router receives the packets and then determines the most efficient way to send the packets to the recipient.
How TCP/IP Works n After traveling along a series of routers, the packets arrive at their destination. n Upon arrival at their destination, TCP checks the data for corruption against the header included in each packet. If TCP finds a bad packet, it sends a request that the packet be re-transmitted.
IP Addresses n Since computers process numbers more efficiently and quickly than characters, each machine directly connected to the Internet is given an IP Address n An IP address is a 32-bit address comprised of four 8-bit numbers separated by periods. Each of the four numbers has a value between 0 and 255
IPv4 Addresses n Example of an IP Address: 128.123.64.147 The IP Address of the Computer Science Department s Web Server at NMSU www.cs.nmsu.edu
IPv6 Addresses n New addressing system developed in 1995 n The IP version 4 address space is rapidly nearing exhaustion of available address blocks l Uses 128 bits for the address provides the potential for a maximum of 2 128, or about 3.403 10 38 unique addresses Hexadecimal notation
Special IP Numbers n Some IP numbers have special meanings, and so are not normally assigned to individual hosts n Broadcast Address 255 Listened to by all machines on the network n Loopback Network 127 127.0.0.1 - loopback address (localhost)
DNS n While numeric IP addresses work very well for computers, most humans find it difficult to remember long patterns of numbers. n Instead, humans identify computers using Uniform Resource Locators (URLs), a.k.a. Web Addresses. n A domain name server (DNS) is a machine that keeps a table of names and corresponding IP addresses
DNS n When a human types a URL into a browser, the request is sent to a Domain Name Server (DNS), which then translates the URL to an IP address understood by computers. n The DNS acts like a phonebook.
DNS n There are 13 DNS root servers in the world (mirrored) n when an application specifies a host name, go to local domain name server and try lookup if not stored there, then local DNS requests address from a root server root server determines appropriate name server & forwards request n nslookup: A command to find host name of an IP address and vice versa. Type nslookup at the DOS prompt and then hit enter.
Anatomy of a URL http://www.cs.nmsu.edu/index.htm protocol service name sub-sub domain sub domain domain name file name
What about Email Addresses? Myname@cs.nmsu.edu sub-sub domain domain name username sub-domain
Top Level Domain Names.edu.gov.mil.com.net.org Educational Institution Governmental Agency Military Entity Commercial Entity Internet Service Provider Non-Profit Organization
Internet Protocols http:// mailto: ftp:// telnet: World Wide Web E-mail address File Transfer Protocol Telnet
HTTP n HTTP is the protocol used by the WWW n When a user clicks on a hyperlink in their web browser, this sends an HTTP command to the Web server. n This command is called GET and it is used to get the contents of the web page and return them to the user s browser. n It is a very simple protocol It relies on the TCP/IP functionality
Caching n browsers cache pages to save downloading maintain temporary storage (cache) for recent pages when a page is requested, check to see if already in cache if not in the cache, issue GET request when response message arrives, display page and store in cache. if already stored in the cache, send GET request with If- Modified-Since header set to the data of the cached page when response message arrives, if status code 200, then display and store in cache if status code 304, then display cached version instead
Cookies n A cookie is a collection of information about the user n Web server can download a cookie to the client s machine in a response message n When the user returns to URL on the same web server, the browser returns the cookie data as part of its request n Many e-commerce applications require persistent memory of customer interactions e.g., amazon.com remembers your name, credit card, past purchases, interests
Intranets and Extranets n Intranet: A network based on TCP/IP protocols belonging to an organization, usually a corporation, accessible only by the organization's members, employees, or others with authorization. Like the Internet itself, intranets are used to share information. Secure intranets are now the fastestgrowing segment of the Internet because they are much less expensive to build and manage.
Intranets and Extranets n Extranets: An organization network that allows access to outside networks such as the Internet. It allows users outside a company to communicate with its employees over the Internet. An extranet may be viewed as an intermediate network between the Internet and an intranet.
Firewall n A system designed to prevent unauthorized access to or from a private network. Firewalls can be implemented in both hardware and software, or a combination of both. n Firewalls are frequently used to prevent unauthorized Internet users from accessing private networks connected to the Internet, especially intranets. n All messages entering or leaving the intranet pass through the firewall, which examines each message and blocks those that do not meet the specified security criteria.
Thank You Questions??