HTTP

 


Overview

The HTTP protocol defines the requests that a client can send to a server and the responses that the server can send in reply. Each request contains a URL, which is a string that identifies a Web component or a static object such as an HTML page or image file. The J2EE server converts an HTTP request to an HTTP request object and delivers it to the Web component identified by the request URL. The Web component fills in an HTTP response object, which the server converts to an HTTP response and sends to the client. Internet RFCs for HTTP include 1945 (HTTP/1.0) and ftp://ftp.isi.edu/in-notes/rfc2616.txt">2616 (HTTP/1.1).

 


HTTP Requests

An HTTP request consists of a request method, a request URL, header fields, and a body. HTTP 1.1 defines the following request methods:

GET Retrieves the resource identified by the request URL
HEAD Returns the headers identified by the request URL
POST Sends data of unlimited length to the Web server
PUT Stores a resource under the request URL
DELETE Removes the resource identified by the request URL
OPTIONS Returns the HTTP methods the server supports
TRACE Returns the header fields sent with the TRACE request

HTTP 1.0 includes only the GET, HEAD, and POST methods. Although J2EE servers are only required to support HTTP 1.0, in practice many servers, including the one contained in the J2EE SDK, support HTTP 1.1.

 


HTTP Responses

An HTTP response contains a result code, header fields, and a body. The HTTP protocol expects the result code and all header fields to be returned before any body content.

Some commonly used status codes include the following:

404 Indicates that the requested resource is not available
401 Indicates that the request requires HTTP authentication
500 Indicates an error inside the HTTP server which prevented it from fulfilling the request
503 Indicates that the HTTP server is temporarily overloaded, and unable to handle the request


 

Home