The Java Program: PostQuery.java

  1 import Query;
  2 import java.net.URL;
  3 import java.net.URLConnection;
  4 import java.io.InputStream;
  5 import java.io.PrintWriter;
  6 import java.io.IOException;
  7 
  8 class PostQuery extends Query {
  9 
 10    PostQuery (String u) { url_name = u; }
 11 
 12    public InputStream send () throws IOException {
 13       final URL CGIurl = new URL (url_name);
 14       final URLConnection c = CGIurl.openConnection();
 15       c.setDoOutput(true);   // output is planned to this URL
 16       c.setDoInput (true);   // input is planned from this URL
 17       c.setAllowUserInteraction (false);  // no password, etc
 18       final PrintWriter out = new PrintWriter (c.getOutputStream());
 19       out.print (query);
 20       out.close();
 21       return (c.getInputStream());
 22    }
 23 
 24 }