Kiến trúc Web Platform • Hardware • Software modules & configurations • Choice of software platform e.g., J2EE, .NET Mô hình hóa các tiến trình xử lý Trong một lĩnh vực cụ thể
Trang 1Kiến trúc Web
Trang 2Nội dung
Trang 3Kiến trúc Web
Platform
• Hardware
• Software modules & configurations
• Choice of software platform (e.g., J2EE, NET)
Mô hình hóa các tiến trình xử lý
Trong một lĩnh vực cụ thể
Trang 4Kiến trúc Web Platform
Web platform dựa trên các thành phần sau
application server, database, web services)
Trang 5HTTP Server
HTTP for transport
URL/URI for addressing
HTML/XHTML
for display
PHP, python etc
for interaction
Trang 6Mô hình Web (các tầng giao thức)
SONET interface
IP
SONET interface
Ethernet interface
Trang 8Giao dịch của HTTP
một response (một phản hồi của một request nào đó) giữa web client và web server
GET / HTTP/1.1 Accept: image/gif, image/x-xbitmap, image/ jpeg, image/pjpeg, */*
Accept-Language: en-us Accept-Encoding: gzip, deflate User-Agent: Mozilla/4.0 (compatible;
MSIE 5.01; Windows NT) Host: www.eurecom.fr Connection: Keep-Alive
server
HTTP/1.1 200 OK Date: Mon, 15 Jul 2002 08:49:00 GMT Server: Apache/1.3.26 (Unix) PHP/4.2.1 Last-Modified: Wed, 12 Jun 2002 08:49:49 GMT
ETag: "2a-50ea-3d070b2d"
Accept-Ranges: bytes Content-Length: 20714 Keep-Alive: timeout=15, max=100 Connection: Keep-Alive
Content-Type: text/html
<html>
HTML
Trang 9HTTP Message
Một dòng yêu cầu
Method Request-URI HTTP-Version (Request-Line)
HTTP-Version Status-Code Reason-Phrase (Status-Line)
Trang 10Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 5.01; Windows NT)
Host: www.eurecom.fr
Connection: Keep-Alive
<CR>
GET /foo.html HTTP/1.1 — request "/foo.html" using HTTP version 1.1
Accept: — types of documents accepted by browser
Accept-Language: — preferred language is english
Accept-Encoding: — browser understands compressed documents
User-Agent: — identification of browser (real type is IE 5.01)
Host: — what the client thinks the server host is
Connection: — keep TCP connection open until explicitly disconnected
Trang 11HTTP Response
HTTP/1.1 200 OK
Date: Mon, 15 Jul 2002 08:49:00 GMT
Server: Apache/1.3.26 (Unix) PHP/4.2.1
Last-Modified: Wed, 12 Jun 2002 08:49:49 GMT
HTTP/1.1 200 OK — document found (code 200); server is using HTTP 1.1
Date: — current date at the server
Server: — software run by the server
Last-Modified: — most recent modification of the document
ETag: — entity tag (unique identifier for the server resource, usable for caching)
Accept-Ranges: — server can return subsections of a document
Content-Length: — length of the body (which follows the header) in bytes
Connection: — the connection will close after the server's response
Content-Type: — what kind of document is included in the response
<html> — document text (follows blank line)
Trang 12Client Methods
GET
Retrieve a resource from the
server (static file, or
dynamically-generated data)
HEAD
Get information about a
resource (but not the actual
resource)
POST
Client provides some
information to the server, e.g.,
through forms (may update
the state of the server)
PUT
Provide a new or replacement
resource to put on the server
TRACE (HTTP 1.1)
Ask proxies to declare themselves in the headers (used for debugging)
CONNECT (HTTP 1.1)
Used for HTTPS (secure HTTP) through a proxy
Trang 13HTTP Caching
Improves Web performance, reduces load on server
Cache control directives in HTTP header (no cache, age, etc.)
GET http://origin/
Client 1
Cache server Origin server
Trang 14HTTP Client Authentication
Basic scheme: username:password base-64 encoded
echo -n “user:password" | openssl base64
echo "c2NvdHQ6dGlnZXI=" | openssl base64 -d
HTTP/1.1 401 Unauthorized WWW-Authenticate: Basic realm="secret"
GET /private/ HTTP/1.1 Authorized: Basic SHY3GH7D3SH==
Username: joe Password: ********
Trang 15Cookies
trạng thái của Client
Dùng cặp khóa – giá trị
Thường dùng quản lý các
phiên giao dịch session
Cookie có thể truy xuất bởi
một site/domain
Server có thể định thời gian
hết hạn
Client có thể từ chối cookie,
giới hạn kích thước, thời
gian…
Client
Origin server
GET http://origin/
200 OK Set-Cookie: ABC=XYZ
GET http://origin/
Cookie: ABC=XYZ
200 OK
Trang 16Mô hình: Model View Controller
(1979)
Trang 17Mô hình: Model View Controller
ứng dụng
thành phần của giao diện người dùng
Quản lý sự trao đổi dữ liệu
tác liên quan đến mô hình
Trang 18Model-View-Controller 2 cho
Web
Kết nối không bền vững giữa client và server
Truy vấn lại server để phát hiện những thay đổi
Trang 20Client/Server (2-Layer)
Trang 21Backend
(Legacy Application, Enterprise Info System)
Business Layer
Data Layer
Trang 22N-Layer Architectures
Trang 23Vì sao dùng N-Layer Architecture?
Trang 24JSP-Model-1 Architecture