//Sample Code to Submit a Form
import java.net.*;
import java.io.*;


class insearch
  {
  static public void main(String [] argv) throws Exception
    {
    URL url=new URL("http://www.internic.net/cgi-bin/whois");
    HttpURLConnection conn=(HttpURLConnection)url.openConnection();
    int c;
    conn.setDoInput(true);
    conn.setDoOutput(true);
    conn.setRequestMethod("POST");
    conn.setRequestProperty("Content-type",
        "application/x-www-form-urlencoded");
    conn.connect();
    PrintWriter pout = new 
        PrintWriter( new 
        OutputStreamWriter(conn.getOutputStream(), 
        "8859_1"), true );
    pout.print("whois_nic=" + URLEncoder.encode(argv[0]) + 
        "&submit=Search&type=domain");
    pout.flush();
      // read results
    System.out.println(conn.getResponseMessage());
    InputStream is=conn.getInputStream();
    do 
      {
      char x;
      c=is.read();
      x=(char)c;
      if (c!=-1) System.out.print(x);
      } while (c!=-1);
    }
  }
