12.07.2015 Views

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

Beginning Java EE 6 with GlassFish 3, Second Edition

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 15 ■ RESTFUL WEB SERVICESFor instance, here is a type of request sent to a server:$> curl -v http://www.apress.com/book/catalog?category=32> GET /book/catalog?category=32 HTTP/1.1> User-Agent: curl/7.19.3 (i586-pc-mingw32msvc) libcurl/7.19.3 zlib/1.2.3> Host: www.apress.com> Accept: */*This request has several pieces of information sent from the client:• The HTTP method, here GET• The path, here /book/catalog?category=32• Several other request headersNotice that there is no body as part of the request. Actually, a GET never has a body. To the request,the server will send the following response:< HTTP/1.1 200 OK< Date: Mon, 23 Feb 2009 07:28:09 GMT< Server: Apache/2.0.63 (Unix) PHP/5.2.6< X-Powered-By: PHP/5.2.6< Set-Cookie: PHPSESSID=b9ae64b800781d9761670fcf6067a317; path=/< Expires: Thu, 19 Nov 1981 08:52:00 GMT< Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0< Pragma: no-cache< Transfer-Encoding: chunked< Content-Type: text/html...This response is made up of the following:• A response code: In this case, the response code is 200 OK.• Several response headers: In the preceding code, the response headers are Date,Server, Content-Type. Here the content type is text/html, but it could be any othermedia such as XML (application/xml) or images (image/jpeg).• Entity body, or representation: The content of the returned web page is the entitybody in this example (here I just showed a fragment of an HTML page).454

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!