home *** CD-ROM | disk | FTP | other *** search
/ CGI How-To / CGI HOW-TO.iso / java / mult_j / mult.jav < prev   
Encoding:
Text File  |  1996-06-15  |  1.0 KB  |  58 lines

  1. import java.util.*;
  2. import Cgi;
  3.  
  4. public class Mult extends Object
  5. {
  6.  
  7.     public static void main(String argv[])
  8.     {
  9.         /* Variables for the data. */
  10.     
  11.         Hashtable dataDict;
  12.         Enumeration iter;
  13.         String key,value;
  14.         Vector avalue;
  15.     
  16.         /* 
  17.          * Print the header required for all CGI scripts
  18.          * that output dynamic text data.
  19.          */
  20.         System.out.print("Content-type: text/plain\n\n");
  21.     
  22.         System.out.println("The form data is:\n");
  23.     
  24.         dataDict = Cgi.readParse();
  25.     
  26.         iter = dataDict.keys();
  27.     
  28.         while(iter.hasMoreElements())
  29.         {
  30.             key = (String) iter.nextElement();
  31.     
  32.             /* See if this is an array, if not, print it */
  33.         
  34.             if(key.startsWith("A_"))
  35.             {
  36.                 int i,max;
  37.             
  38.                 avalue = (Vector) dataDict.get(key);
  39.             
  40.                 max = avalue.size();
  41.             
  42.                 System.out.println("Found a key with multiple values:");
  43.             
  44.                 key = key.substring(2,key.length());
  45.             
  46.                 for(i=0;i<max;i++)
  47.                 {
  48.                     System.out.println(key + "=" + avalue.elementAt(i));
  49.                 }
  50.             }
  51.             else
  52.             {
  53.                 System.out.println(key + "=" + dataDict.get(key));
  54.             }
  55.         }
  56.     }
  57. }
  58.