public static void main(String args[]){
  try {
    String command, param;
    int delim=QueryString.indexOf("=");
    if (delim == -1) {
      command=QueryString;
      param="";
    }
 else {
      command=QueryString.substring(0,delim);
      param=QueryString.substring(delim + 1);
    }
    CGICommandHandler handler=commandLookup.get(command);
    if (handler != null)     try {
      handler.execute(param);
    }
 catch (    CGIClientException e) {
      e.printStackTrace();
      returnClientError(e.getMessage());
    }
catch (    CGIServerException e) {
      e.printStackTrace();
      returnServerError(e.getMessage());
    }
 else     returnClientError("invalid command.");
  }
 catch (  Exception e) {
    e.printStackTrace();
    returnServerError("internal error: " + e.getMessage());
  }
  System.exit(0);
}

public static void main ( String args [ ] ) { try { String command , param ; int delim = QueryString . indexOf ( "=" ) ; if ( delim == - 1 ) { command = QueryString ; param = "" ; } else { command = QueryString . substring ( 0 , delim ) ; param = QueryString . substring ( delim + 1 ) ; } CGICommandHandler handler = commandLookup . get ( command ) ; if ( handler != null ) try { handler . execute ( param ) ; } catch ( CGIClientException e ) { e . printStackTrace ( ) ; returnClientError ( e . getMessage ( ) ) ; } catch ( CGIServerException e ) { e . printStackTrace ( ) ; returnServerError ( e . getMessage ( ) ) ; } else returnClientError ( "invalid command." ) ; } catch ( Exception e ) { e . printStackTrace ( ) ; returnServerError ( "internal error: " + e . getMessage ( ) ) ; } System . exit ( 0 ) ; }
execute command given in query string on url . the string before the first ' = ' is interpreted as the command name , and the string after the first ' = ' is the parameters to the command .
