import java.net.*;
import java.io.*;

        // Use the POST method to send a string to a CGI script.
        // This involves writing to the URL connection.
class CGIPostClient extends CGIClient {
    public CGIPostClient(String resource) throws Exception {
        super(resource);
    }

        // Write whatToPost to the URL connection and read
        // back the response.
    public String post(String whatToPost) throws IOException {
        URLConnection connection = getConnection();

        // Indicate that we wish to send output to the script.
        connection.setDoOutput(true);
        // Send whatToPost.
        Writer writer = new OutputStreamWriter(connection.getOutputStream());
        writer.write(whatToPost);
        writer.close();

        return getResponse();
    }
}
