2. Topic
No programming detail
Not for some specific programming
language
Focus on what it is
Focus on how it works
3. Outline
Client Server Communication
HTTP
Static Web
Web Server
Client Side Script
Dynamic Web
Application Server
Beyond This
4. Client Server Communication
Server listen
Client send a request
Server send a response back
OSI Stack
– Application Layer
– Transport Layer
– Network Layer
– Data Link Layer
– Physical Layer
5. HTTP
Application Layer Protocol
URL As Address
Address Stack
– HTTP: URL (domain + path)
– TCP: ip + port
– IP: ip
– 802.11x: mac address
– Hardware: broadcast
6. HTTP
HTTP Request
– Header (Key-Value Text)
• Address (Host, Get or Post)
• Describe Body
• Describe Client
• Other Stuff
– Body
• Post Parameters (key=value)
• Files
• Carry whatever you want
7. HTTP
HTTP Response
– Header (Text Key Value Pairs)
• Response Status (2xx 3xx 4xx 5xx)
• Describe Body
• Other Stuff
– Body
• Browser case : HTML js css
• Download case : anything you downloaded
8. Static Web
Document Sharing
Connection between Documents – Hyper
Link
Document is text and more than text
Hyper Text = text + hyper link
HTML = Hyper Text + style
Hyper Text Markup Language
9. Web Server
Manage static document files
Give client what it ask for
Apache Lighttpd Nginx etc
How it works
– Listen on a port (default 80)
– Accept a http request
– Locate the document client wants
– Send that back to client as a http response
10. Client Side Script
More than display and link
– Animation
– Response user action immediately
– Some logic can run on client
Browser can run
– Javascript
– Flash
– Sliver light
– VB Script, Java Applet, ActiveX, Extensions
11. Dynamic Web
Think about a forum
– User generate content
– Topics changes all the time
You can not do this static way
– We need more then static files
– We need to run a program when we accept
a http request to generate response
How?
12. Dynamic Web
New Way
– Listen to a port (default 80)
– Accept a http request
– Processing request
• If static content, return that stupid file
• If dynamic run a program return that result
– Send result back as a http response
13. Application Server
More then web server
– An URL can map to a static file
– An URL can map to a processing logic
Ancient Way
– CGI just run a executable program and
return the standard output
– Fast CGI : thread based
14. Application Server
Now it works, functionally
People finally got Web Application
But it sucks
– If we write an address which we should not
write, Crash!
– Print each line of html
– Heavy work just for a forum
15. Application Server
Most Web Applications do not need
memory manipulate
Output html in html way
Solution
– Interpret server side script in a html
template when processing a request
– Php is short for Php Home Page
– Asp jsp rhtml
17. Application Server
How it works
– Listen to a port (default 80)
– Accept a http request
– Processing request
• If static content, return that stupid file
• If dynamic
– Run the interpreter such as php interpreter
– The interpreter interpret user program(php file)
– Interpreter return the interpret result
– Send result back as a http response
18. Application Server
PHP style language limitation
– Each interpreter instance for a request
– No server global context
– Low performance nature
JAVA style (JAVA .NET)
– Virtual machine execution (keep
programmer from low level memory ops)
– Compile instead interpret (greatly improve
performance)
– Web app and server all run in One VM
19. Application Server
How it works (JAVA style)
– JVM start a JAVA program (that's server)
– Listen to a port (default 80)(run in VM)
– Accept a http request (run in VM)
– Processing request (run in VM)
• If static content, return that stupid file
• If dynamic
– Parse the http request
– Call the user define method which should
process this request,
– Send result back as a http response(run in
VM)
20. Application Server
JAVA program server should be
– Tomcat (widely used)
– Jetty (we use in current project)
– Websphere (widely used in commercial)
The user define method should be
– doGet(request, response)
– doPost(request, response)
21. Beyond This
Web Service
Web Socket
High Performance Web
High Availability
Distribute Web