public class UpdateClient {
  public static void main(String[] args)
    throws Exception {
    if (args.length < 2)
      System.exit(-2);
    String url, jarName, remoteLocation = null;
    url = args[0];
    jarName = args[1];
    String fullURL = null;
    if (args.length == 3) {
      remoteLocation = args[2];
      fullURL = url + "/JSPupdate?jarName=" +
        jarName + "&remoteLocation="
        + URLEncoder.encode(remoteLocation) +
        "&Submit=JSPupdate";
    } else {
      fullURL = url + "/JSPupdate?jarName=" +
        jarName +
        "&remoteLocation=&Submit=JSPupdate";
    }
    InputStream is=(new URL(fullURL)).openStream();
    if (is == null)
      System.exit(-1);
    BufferedReader br = new BufferedReader(
      new InputStreamReader(is));
    while(true) {
      String line = br.readLine();
      if (line == null)
        System.exit(-1);
      if (line.indexOf("No JAR name supplied!")
        != -1)
        System.exit(-1);
      if ((line.indexOf("handler created!")
        != -1) ||
        (line.indexOf("JAR loaded!") != -1) ||
        (line.indexOf("JAR updated!") != -1))
        System.exit(1);
    }
  }
}