Apache Tomcat 6.0.43

org.apache.catalina.servlets
Class CGIServlet.CGIRunner

java.lang.Object
  extended by org.apache.catalina.servlets.CGIServlet.CGIRunner
Enclosing class:
CGIServlet

protected class CGIServlet.CGIRunner
extends java.lang.Object

Encapsulates the knowledge of how to run a CGI script, given the script's desired environment and (optionally) input/output streams

Exposes a run method used to actually invoke the CGI.

The CGI environment and settings are derived from the information passed to the constuctor.

The input and output streams can be set by the setInput and setResponse methods, respectively.


Constructor Summary
protected CGIServlet.CGIRunner(java.lang.String command, java.util.Hashtable env, java.io.File wd, java.util.ArrayList params)
          Creates a CGIRunner and initializes its environment, working directory, and query parameters.
 
Method Summary
protected  java.lang.String[] hashToStringArray(java.util.Hashtable h)
          Converts a Hashtable to a String array by converting each key/value pair in the Hashtable to a String in the form "key=value" (hashkey + "=" + hash.get(hashkey).toString())
protected  boolean isReady()
          Gets ready status
protected  void run()
          Executes a CGI script with the desired environment, current working directory, and input/output streams This implements the following CGI specification recommedations: Servers SHOULD provide the "query" component of the script-URI as command-line arguments to scripts if it does not contain any unencoded "=" characters and the command-line arguments can be generated in an unambiguous manner.
protected  void setInput(java.io.InputStream stdin)
          Sets standard input to be passed on to the invoked cgi script
protected  void setResponse(javax.servlet.http.HttpServletResponse response)
          Sets HttpServletResponse object used to set headers and send output to
protected  void updateReadyStatus()
          Checks & sets ready status
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CGIServlet.CGIRunner

protected CGIServlet.CGIRunner(java.lang.String command,
                               java.util.Hashtable env,
                               java.io.File wd,
                               java.util.ArrayList params)
Creates a CGIRunner and initializes its environment, working directory, and query parameters.
Input/output streams (optional) are set using the setInput and setResponse methods, respectively.

Parameters:
command - string full path to command to be executed
env - Hashtable with the desired script environment
wd - File with the script's desired working directory
params - ArrayList with the script's query command line paramters as strings
Method Detail

updateReadyStatus

protected void updateReadyStatus()
Checks & sets ready status


isReady

protected boolean isReady()
Gets ready status

Returns:
false if not ready (run will throw an exception), true if ready

setResponse

protected void setResponse(javax.servlet.http.HttpServletResponse response)
Sets HttpServletResponse object used to set headers and send output to

Parameters:
response - HttpServletResponse to be used

setInput

protected void setInput(java.io.InputStream stdin)
Sets standard input to be passed on to the invoked cgi script

Parameters:
stdin - InputStream to be used

hashToStringArray

protected java.lang.String[] hashToStringArray(java.util.Hashtable h)
                                        throws java.lang.NullPointerException
Converts a Hashtable to a String array by converting each key/value pair in the Hashtable to a String in the form "key=value" (hashkey + "=" + hash.get(hashkey).toString())

Parameters:
h - Hashtable to convert
Returns:
converted string array
Throws:
java.lang.NullPointerException - if a hash key has a null value

run

protected void run()
            throws java.io.IOException
Executes a CGI script with the desired environment, current working directory, and input/output streams

This implements the following CGI specification recommedations:

Throws:
java.io.IOException - if problems during reading/writing occur
See Also:
Runtime.exec(String command, String[] envp, File dir)

Apache Tomcat 6.0.43

Copyright © 2000-2014 Apache Software Foundation. All Rights Reserved.