Home TOC |
Search
Feedback |
HTTP Overview
Most web-based J2EE clients use the HTTP protocol to communicate with a J2EE server. HTTP defines the requests that a client can send to a server and 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.
This appendix provides some introductory material on the HTTP protocol. For further information on this protocol, see the Internet RFCs: HTTP/1.0 - RFC 1945, HTTP/1.1 - RFC 2616, which can be downloaded from
http://www.rfc-editor.org/rfc.htmlHTTP 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 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:
- 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 TOC |
Search
Feedback |