# Can somebody explain the HTTP headers in simpler terms in JSP context?

JSPJava 8Object Oriented ProgrammingProgramming

When a Web server responds to an HTTP request, the response typically consists of a status line, some response headers, a blank line, and the document. A typical response looks like this −

HTTP/1.1 200 OK
Content-Type: text/html
...
(Blank Line)
<!doctype ...>

<html>
<body>
...
</body>
</html>

The status line consists of the HTTP version (HTTP/1.1 in the example), a status code (200 in the example), and a very short message corresponding to the status code (OK in the example).

Following is a summary of the most useful HTTP 1.1 response headers which go back to the browser from the web server. These headers are frequently used in web programming −

1Allow
This header specifies the request methods (GET, POST, etc.) that the server supports.
2Cache-Control
This header specifies the circumstances in which the response document can safely be cached. It can have values public, private or no-cache etc. Public means document is cacheable, Private means document is for a single user and can only be stored in private (nonshared) caches and no-cache means document should never be cached.
3Connection
This header instructs the browser whether to use persistent HTTP connections or not. A value of close instructs the browser not to use persistent HTTP connections and keep-alive means using persistent connections.
4Content-Disposition
This header lets you request that the browser ask the user to save the response to disk in a file of the given name.
5Content-Encoding
This header specifies the way in which the page was encoded during transmission.
6Content-Language
This header signifies the language in which the document is written. For example, en, en-us, ru, etc.
7Content-Length
This header indicates the number of bytes in the response. This information is needed only if the browser is using a persistent (keep-alive) HTTP connection.
8Content-Type
This header gives the MIME (Multipurpose Internet Mail Extension) type of the response document.
9Expires
This header specifies the time at which the content should be considered out-of-date and thus no longer be cached.
10Last-Modified
This header indicates when the document was last changed. The client can then cache the document and supply a date by an If-Modified-Since request header in later requests.
11Location
This header should be included with all responses that have a status code in the 300s. This notifies the browser of the document address. The browser automatically reconnects to this location and retrieves the new document.
12Refresh
This header specifies how soon the browser should ask for an updated page. You can specify time in a number of seconds after which a page would be refreshed.
13Retry-After
This header can be used in conjunction with a 503 (Service Unavailable) response to tell the client how soon it can repeat its request.