[0001]
[0002]
[0003]
[0004]
[0005]
[0006]
[0007]
[0008]
[0009]
[0010]
[0011]
[0012]
[0013]
[0014]
[0015]
[0016]
[0017]
[0018]
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
[0026]
[0027]
[0028]
[0029]
[0030]
[0031]
[0032]
[0033]
[0034]
[0035]
[0036]
[0037]
[0038]
[0039]
[0040]
[0041]
[0042]
[0043]
[0044]
[0045]
[0046]
[0047]
[0048]
[0049]
// dumpCGI.java
// Compile using: $ javac "dumpCGI.java"
//
// 02-DEC-2014  MGD  X-record0-mode to handle "empty" newlines 
// 03-JUN-2000  MGD  less sloppy CGI, add header!
// 03-SEP-1998  MGD  changes in line with JDK 1.1.6 final release
// 09-DEC-1997  MGD  initial
//
// Dump CGI variable values using the CGIplus class for a "CGI" script.
// Can be invoked using ... http://host/cgiplus-bin/dumpcgi.class

import java.io.*;

public class dumpcgi {

   private static CGIplus cgienv = new CGIplus();
   private static String nameValue = null;

   public static void main (String args[]) {

      // CGI-compliant plain-text header (and pre-expired)
      System.out.print("Content-Type: text/plain\n" +
                       "Script-Control: X-record0-mode=1\n" +
                       "Expires: Thu, 01-Jan-1970 00:00:01 GMT\n\n");

      System.out.println("There are " +
                         cgienv.getCgiVarCount() +
                         " CGI variables ...");
      System.out.println();
      while ((nameValue = cgienv.nextCgiVar()) != null)
         System.out.println(nameValue);

      // an alternative would have been ...
      // cgienv.dumpCgiVar();

      if (cgienv.isPOSTedForm())
      {
         System.out.println(cgienv.getCgiVar("CONTENT_TYPE"));

         cgienv.dumpForm();

         while ((nameValue = cgienv.nextFormField()) != null)
            System.out.println(nameValue);

         System.out.println(cgienv.getFormField("hidden2"));
         System.out.println(cgienv.getFormField("hidden3"));
      }
   }
}