Introductiontowebarchitecture 090922221506 Phpapp01
Introductiontowebarchitecture 090922221506 Phpapp01
http://chamnapchhorn.blogspot.com
/
Twitter: http://twitter.com/chamnap
Rails Developer
JavaScript Developer
Basic Web Architecture
HTML
URI
HTTP
Web Architecture Extension
Cookie
Session
Database-driven Website Architecture
AJAX
Web Services
XML
JSON
The web is a two-tiered architecture.
› A web browser displays information content,
› and a web server that transfers information
to the client.
A web browser is a software application
for retrieving, presenting, and traversing
information resources on the World Wide
Web.
The primary purpose of a web browser is
to bring information resources to the
user.
The major web browsers are Windows
Internet Explorer, Mozilla Firefox, Apple
Safari, Google Chrome, and Opera.
The term web server or webserver can
mean one of two things:
› A computer program that accepts HTTP
requests and return HTTP responses with
optional data content.
› A computer that runs a computer program
as described above.
In 1989, Tim Berners-Lee
had suggested a way to
let all users, but
particularly scientists,
browse each others’
papers on the Internet.
He developed HTML,
URLs, and HTTP.
Document layout language (not a
programming language)
Defines structure and appearance of
Web pages
Many HTML documents are the result of
manual authoring or word processing
HTML converters.
HTML files are viewed using a web
browser.
URLs are location dependent
It contains four distinct parts: the protocol
type, the machine name, the directory
path and the file name.
There are several kinds of URLs: file URLs, FTP
URLs, and HTTP URLs.
HTTP is an application-level protocol for
distributed, collaborative, hypermedia
information systems.
HTTP is a request/response standard of a
client and a server.
Typically, an HTTP client initiates a
request.
Resources to be accessed by HTTP are
identified using Uniform Resource Identifiers
(URIs).
The request message consists of the
following:
› Request line
› Headers (Accept-Language, Accept,
….)
› An empty line
› An optional message body
METHOD /path-to-resource HTTP/version-
number
Header-Name-1: value
Header-Name-2: value
[ optional request body ]
HTTP defines eight methods (sometimes
referred to as "verbs") indicating the desired
action to be performed on the identified
resource.
› HEAD
› GET
› POST
› PUT
› DELETE
› TRACE
› OPTIONS
› CONNECT
HEAD, GET, OPTIONS and TRACE are
defined as safe (no side effects).
POST, PUT and DELETE are intended for
actions which may cause side effects
either on the server.
Server Message Format
HTTP/version-number status-code message
Header-Name-1: value
Header-Name-2: value
[ response body ]
The first line of the HTTP response is called
the status line.
The way the user agent handles the
response primarily depends on the code
and secondarily on the response
headers.
Success: 2xx
Redirection: 3xx
Client-Side Error: 4xx
Server-Side Error: 5xx
HTTP is a stateless protocol.
Hosts do not need to retain information
about users between requests.
Statelessness is a scalability property.
For example, when a host needs to
customize the content of a website for a
user. Solution:
› Cookies
› Sessions
› Hiddren variables (when the current page is a
form)
› URL encoded parameters (such as /index.php?
session_id=some_unique_session_code)
Client request
Server response
This basic web architecture is fast evolving
to serve a wider variety of needs beyond
static document access and browsing.
CGI extends the architecture to three-tiers
by adding a back-end server that provides
services to the Web server.
Common Gateway Interface
CGI is a standard protocol for interfacing
external application software with a web
server.
CGI programs are executable programs
that run on the Web server.
The CGI program typically returns HTML
pages that it constructs on the fly.
JavaScript is a scripting language designed
for creating dynamic, interactive Web
applications that link together objects and
resources on both clients and servers.
› Getting your Web page to respond or react
directly to user interaction with form elements
and hypertext links
› Preprocessing data on the client before
submission to a server
› Changing content and styles
Cookie is a small piece of text stored on a
user's computer by a web browser.
A cookie consists of one or more name-
value pairs containing bits of information
such as user preferences.
It is sent as an HTTP header by a web server
to a web browser and then sent back
unchanged by the browser each time it
accesses that server.
A cookie can be used for authenticating,
session tracking (state maintenance), and
remembering specific information about
users.
Cookies expire, and are therefore not sent
by the browser to the server, under any of
these conditions:
1. At the end of the user session (i.e. when the
browser is shut down) if the cookie is not
persistent
2. An expiration date has been specified, and has
passed
3. The expiration date of the cookie is changed
(by the server or the script) to a date in the past
4. The browser deletes the cookie by user request
In server-side processing, the Web server:
› Receives the dynamic Web page request
› Performs all of the processing necessary to
create the dynamic Web page
› Sends the finished Web page to the client for
display in the client’s browser
Client-side processing
› Some processing needs to be “executed” by
the browser, either to form the request for
the dynamic Web page or to create or
display the dynamic Web page.
Eg. Javascript code to validate user input
Server-side Client-side
› PHP
processing processing
› ASP › CSS
› ASP.NET
› HTML
› Perl
›
› J2EE JavaScript
› Python, e.g. Django ›
› Ruby, e.g. Ruby on Adobe
Rails Flex
› ColdFusion
›
Microsoft
Web Service is a software system
designed to support machine-to-
machine interaction over a network.
Web services are frequently just Internet
Application Programming Interfaces
(API) that can be accessed over a
network.
Web Services are platform-independent
and language-independent, since they use
standard XML languages.
Most Web Services use HTTP for transmitting
messages (such as the service request and
response).
Style of Use
› RPC
› SOAP
› REST
RPC