/////// GetFactor.java /////// // this file is the same as RemoteFactor.java except for one line import java.net.URLEncoder; class GetFactor { public static void main(String[] args) { if ( args.length != 1 ) { JavaSystem.err.println("Usage: GetFactor poly"); System.exit(1); } String msg = "polynomial=" + URLEncoder.encode(args[0]); // use CgiUrl and CgiSocket both implement CgiClient // so either will work here CgiClient cc = new CgiSocket(server, port, cgi); // CgiClient cc = new CgiUrl(protocol+"://"+server+cgi); cc.postQuery(msg); TextLines ans = cc.textResponse(); cc.close(); ans.output(System.out); } static String protocol = "http"; static int port = 80; static String server = "SymbolicNet.mcs.kent.edu"; static String cgi = "/cgi-bin/icm.demo?factor+y^2-x^2"; // another cgi program to try // static String cgi = "cgi-bin/jfac?factor+y^2-x^2"; } // to run // java GetFactor '27*y^3-8*x^3'