Class CGIplus
java.lang.Object
   |
   +----CGIplus
  -  public class CGIplus
  
-  extends Object
  
This class allows CGI scripting to be supported relatively simply using
 Java.  Relies on the WASD HTTPd CGIplus environment providing the CGI
 variables in a data stream rather than as process environment variables.
 
 Hence scripts must be activated via mapping rules that execute them within
 the CGIplus environment, although the scripts themselves do not have to
 "persist" in the usual CGIplus script manner, just "System.exit(0)" when
 finished processing (at the slight cost of destroying the subprocess).
 
 Currently supports GET and "x-www-form-urlencoded" POST HTTP method scripts.
 Will be expanded to more fully support POST processing as time permits.
  -  Version:
  
 -  1.0.0, 09-DEC-97
  
 -  Author:
  
 -  MGD
 
  
  -  
	CGIplus()
   -  
 
  
  -  
	begin()
   -   Begin script processing, and synchronize persistant (CGIplus) scripts.
  
 -  
	dumpBody()
   -   Output all lines in request body (for debugging POSTed requests, etc.)
 
  
 -  
	dumpCgiVar()
   -   Output all CGI variable 'name=value' pairs (for debugging, etc.)
 
  
 -  
	dumpForm()
   -   Output all form 'field=value' pairs (for debugging, etc).
  
 -  
	end()
   -   Conclude the response.
  
 -  
	getCgiVar(String)
   -   Return the value of the specified CGI variable name.
  
 -  
	getCgiVarCount()
   -   Return the number of CGI variables available.
  
 -  
	getContentLength()
   -   Returns the content-length of the body for a POSTed request.
  
 -  
	getContentType()
   -   Returns the MIME content-type of the body of a POSTed request.
  
 -  
	getFormField(String)
   -   Return the value of the specified form field name.
  
 -  
	getFormFieldCount()
   -   Return the number of form fields.
  
 -  
	getUsageCount()
   -   Return the number of times the script has been used.
  
 -  
	isPOSTedForm()
   -   Tests whether the request is POSTed and "www-form-urlencoded".
  
 -  
	nextCgiVar()
   -   Successive calls return each CGI variable 'name=value' pair.
  
 -  
	nextFormField()
   -   Successive calls return each form field 'name=value' pair.
  
 -  
	readBodyLine()
   -   Read a line from the body of the request (for POSTed requests).
  
 -  
	urlDecode(String)
   -   Decode the supplied URL-encoded string.
 
  
CGIplus
 public CGIplus()
  
begin
 public void begin()
  -  Begin script processing, and synchronize persistant (CGIplus) scripts.
 For the first call checks for the CGIPLUSEOF string (if not available
 reports it as an error and exits), then opens the CGIPLUSIN stream.
 Wait for a request to become available (first record read and discarded).
 Then read series of records up until the first empty record (indicates end
 of CGI variables), placing each of these records into a vector object for
 later search and retrieval.
  
    -  Returns:
    
 -  none
  
 
 
 
end
 public void end()
  -  Conclude the response.
 Write the CGIplus end-of-output value to the server.
 Release any resources not relevant to next request (if CGIplus).
  
    -  Returns:
    
 -  none
  
 
 
 
getUsageCount
 public int getUsageCount()
  -  Return the number of times the script has been used.
 Relevant only when behaving as a persistant, CGIplus script.
  
    -  Returns:
    
 -  none
  
 
 
 
getCgiVar
 public String getCgiVar(String varName)
  -  Return the value of the specified CGI variable name.
 It is less expensive but not mandatory to supply the the "WWW_" prefix.
 Returns null if the specified variable name does not exist.
  
    -  Parameters:
    
 -  varName - the name of the CGI variable
    
 -  Returns:
    
 -  the CGI variable string
  
 
 
 
nextCgiVar
 public String nextCgiVar()
  -  Successive calls return each CGI variable 'name=value' pair.
 Returns null and resets when the CGI variables are exhausted.
  
    -  Returns:
    
 -  the 'name=value' string
  
 
 
 
getCgiVarCount
 public int getCgiVarCount()
  -  Return the number of CGI variables available.
  
    -  Returns:
    
 -  count of CGI variables
  
 
 
 
dumpCgiVar
 public void dumpCgiVar()
  -  Output all CGI variable 'name=value' pairs (for debugging, etc.)
  
    -  Returns:
    
 -  none
  
 
 
 
getContentType
 public String getContentType()
  -  Returns the MIME content-type of the body of a POSTed request.
  
    -  Returns:
    
 -  body content-type
  
 
 
 
isPOSTedForm
 public boolean isPOSTedForm()
  -  Tests whether the request is POSTed and "www-form-urlencoded".
  
    -  Returns:
    
 -  true or false
  
 
 
 
getContentLength
 public int getContentLength()
  -  Returns the content-length of the body for a POSTed request.
  
    -  Returns:
    
 -  length of POSTed body
  
 
 
 
readBodyLine
 public String readBodyLine()
  -  Read a line from the body of the request (for POSTed requests).
  
    -  Returns:
    
 -  the line (or null if body exhausted)
  
 
 
 
dumpBody
 public void dumpBody()
  -  Output all lines in request body (for debugging POSTed requests, etc.)
  
    -  Returns:
    
 -  none
  
 
 
 
dumpForm
 public void dumpForm()
  -  Output all form 'field=value' pairs (for debugging, etc).
 For a 'x-www-form-urlencoded', POSTed request.
  
    -  Returns:
    
 -  the 'name=value' string
  
 
 
 
getFormField
 public String getFormField(String fieldName)
  -  Return the value of the specified form field name. 
 Returns null if the specified field name does not exist.
 For a 'x-www-form-urlencoded', POSTed request.
  
    -  Parameters:
    
 -  fieldName - the name of the field
    
 -  Returns:
    
 -  the (URL-decoded) field value
  
 
 
 
nextFormField
 public String nextFormField()
  -  Successive calls return each form field 'name=value' pair.
 Returns null and resets when the form fields are exhausted.
 For a 'x-www-form-urlencoded', POSTed request.
  
    -  Returns:
    
 -  the 'name=value' string
  
 
 
 
getFormFieldCount
 public int getFormFieldCount()
  -  Return the number of form fields.
 For a 'x-www-form-urlencoded', POSTed request.
  
    -  Returns:
    
 -  count of fields in request
  
 
 
 
urlDecode
 public String urlDecode(String estr)
  -  Decode the supplied URL-encoded string.
 Converts '+' into ' ' and "%nn" hex-encoded values into their ASCII
 characters.
  
    -  Parameters:
    
 -  estr - the url-encoded string
    
 -  Returns:
    
 -  the decoded string