Jan K. Labanowski: "Tomcat, servlets, JSPs and other friends"

HTTP

Hyper Text Transport Protocol

Header consists of lines in the format: Keyword: value. While body represents actual data. HTTP request (from browser to server) and HTTP response (from server to browser) are structured this way.
  • Browser (client) request example:
    POST /cgi/script HTTP/1.0
    Connection: Keep-Alive
    User-Agent: Mozilla/4.78 [en] (X11; U; Linux 2.4.9-13 i686)
    Host: 127.0.0.1:9999
    Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, image/png, */*
    Accept-Encoding: gzip
    Accept-Language: en
    Accept-Charset: iso-8859-1,*,utf-8
    Content-type: application/x-www-form-urlencoded
    Content-length: 19
    
    name=Jan&sex=mail

  • Server response example:
    HTTP/1.1 200 OK
    Server: Apache/1.2.20 (UNIX)
    Content-Type: text/html
    Content-Length: 1234
    
    <html>
    <head><title>My Page</title></head>
    <body bgcolor="red">
    <h1>The Title</h1>
    ....