Introduction to Web ArchitectureChhorn Chamnap
About MeBlog: http://chamnapchhorn.blogspot.com/Twitter: http://twitter.com/chamnapRails DeveloperJavaScript Developer
AgendaBasic Web ArchitectureHTMLURIHTTPWeb Architecture ExtensionCookieDatabase-driven Website ArchitectureAJAXWeb ServicesXMLJSON
The World Wide Web
The World Wide WebIn 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.
Basic Web Architecture
Basic Web ArchitectureThe web is a two-tiered architecture.A web browser displays information content, and a web server that transfers information to the client.
Web BrowserThe primary purpose is to bring information resources to the user. An application for retrieving, presenting, and traversing information resources.
Web ServerThe 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.
HTMLHyperText Markup Language
HTMLDocument layout language (not a programming language)Defines structure and appearance of Web pages
URIUniversal Resource Identifier
URIURLs 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.
HTTPHyperText Transfer Protocol
HTTPHTTP 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).
Request messageThe request message consists of the following:Request lineHeaders (Accept-Language, Accept, ….)An empty lineAn optional message body
Request methodsHTTP defines eight methods (sometimes referred to as "verbs") indicating the desired action to be performed on the identified resource.HEADGETPOSTPUTDELETETRACEOPTIONSCONNECT
Safe methodsHEAD, 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.
Status CodesThe 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: 5xxHTTP session stateHTTP 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
Hidden variables (when the current page is a form)
URL encoded parameters (such as /index.php?session_id=some_unique_session_code)Sample HTTP Request and ResponseClient requestServer response
Web Architecture Extension
Web Architecture ExtensionCGI extends the architecture to three-tiers by adding a back-end server that provides services to the Web server.
Traditional uses of JavaScriptJavaScript 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 linksPreprocessing data on the client before submission to a serverChanging content and styles
Cookietracking cookie, browser cookie, or HTTP cookie
CookieCookie 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.
A cookie can be used for:
authenticating,
session tracking, and
remembering specific information about users.Setting A Cookie
Cookie ExpirationCookies expire, and are therefore not sent by the browser to the server, under any of these conditions:At the end of the user session if the cookie is not persistent An expiration date has been specified, and has passed The expiration date of the cookie is changed to a date in the past The browser deletes the cookie by user request
Database-driven Website Architecture
Database-driven Website Architecture
Server-side processingIn server-side processing, the Web server:Receives the dynamic Web page requestPerforms all of the processing necessary to create the dynamic Web pageSends the finished Web page to the client for display in the client’s browser
Client-side processingClient-side processingSome 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 and Client side processingServer-side processingPHPASPASP.NETPerlJ2EEPython, e.g. DjangoRuby, e.g. Ruby on RailsColdFusionClient-side processingCSSHTMLJavaScriptAdobe FlexMicrosoft Silverlight
AJAXAsynchronous JavaScript and XML
Defining AjaxAjax isn’t a technology. It’s really several technologies, each flourishing in its own right, coming together in powerful new ways. Ajax incorporates:XHTML and CSS;Document Object Model; XML and XSLT; XMLHttpRequest; JavaScriptJesse James Garrett, essay infebruary 18, 2005 Ajax: A New Approach to Web Applications

Introduction to Web Architecture