Java Reference
In-Depth Information
header. The complete transaction, including client request and server response, looks
something like this:
% telnet www.cafeaulait.org 80
Trying 152.19.134.41...
Connected to www.cafeaulait.org.
Escape character is '^]'.
POST /books/jnp3/postquery.phtml HTTP/1.0
Accept: text/plain
Content-type: application/x-www-form-urlencoded
Content-length: 63
Connection: close
Host: www.cafeaulait.org
username=Elliotte+Rusty+Harold&email=elharo%40ibiblio%2eorg
HTTP/1.1 200 OK
Date: Sat, 04 May 2013 13:27:24 GMT
Server: Apache
Content-Style-Type: text/css
Content-Length: 864
Connection: close
Content-Type: text/html; charset=utf-8
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Query Results</title>
</head>
<body>
<h1>Query Results</h1>
<p>You submitted the following name/value pairs:</p>
<ul>
<li>username = Elliotte Rusty Harold</li>
<li>email = elharo@ibiblio.org</li>
</ul>
<hr />
Last Modified July 25, 2012
</body>
</html>
Connection closed by foreign host.
For that matter, as long as you control both the client and the server, you can use any
other sort of data encoding you like. For instance, SOAP and XML-RPC both POST data
to web servers as XML rather than an x-www-form-url-encoded query string.
Example 7-14 is a program called FormPoster that uses the URLConnection class and
the QueryString class from Chapter 5 to post form data. The constructor sets the URL.
Search WWH ::




Custom Search