Google
 

 

up previous next contents
Up: 3. Day 3: Standard Previous: 3.9 Internationalization, localization, and Next: 3.11 Servlets and JSPs   Contents

Subsections

3.10 HTTP protocol

  • Underlying protocol for all Web Browser/Web Server communication whether static or dynamic.
  • Uses request and response communication model.
  • Cookies

3.10.1 Request and Response

  • Client issues a request to the server.
  • Server processes the request, and responds to the client.
  • The GET verb asks the server for the content at a given URL. The client may specify extra parameters for the server. These query parameters can be seen on the URL in the browser: "http://www.yahoo.com/search?q=java".
  • The POST verb sends data to the server to be processed. This data is packaged in the request a well defined format, and is not visible in the browser. The server responds in the same way as with GET requests.
  • Headers are name value pairs that precede the request or response data. These can indicate such informations as what type of data is being sent, how long it is, and what type of client/server is doing the sender.
  • Example:
    • At the command prompt: telnet www.google.com 80
    • When connected type exactly: GET /index.html HTTP/1.1
    • Hit enter twice - this sends the request.
    • Note the response code - "200 OK" means the server processed the request successfully.
    • Note the headers: Content-Type, Content-Length, a cookie, and the web server type.

3.10.2 Cookies

  • Simple name/value pairs used to store state on the client.
  • Cookies are set when the server sends a Set-Cookie header in a response.
  • The browser sends the server the cookies back in the request headers.
  • The server is only sent the cookies for its domain.
  • Many web application platforms (JSP, servlets, ASP) use cookies for session tracking.
  • Cookies have expiration dates after which they are no longer sent to the server.
  • The total cookie header may not exceed 4K, and client sofware may have more restrictions.
  • Due to security concerns some users turn off cookies in their browsers.