org.apache.catalina.servlets
protected class CGIServlet.CGIRunner extends Object
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.
Version: $Revision: 896371 $, $Date: 2010-01-06 11:30:07 +0100 (Wed, 06 Jan 2010) $
Constructor Summary | |
---|---|
protected | CGIRunner(String command, Hashtable env, File wd, ArrayList params)
Creates a CGIRunner and initializes its environment, working
directory, and query parameters.
|
Method Summary | |
---|---|
protected String[] | hashToStringArray(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:
|
protected void | setInput(InputStream stdin)
Sets standard input to be passed on to the invoked cgi script
|
protected void | setResponse(HttpServletResponse response)
Sets HttpServletResponse object used to set headers and send
output to
|
protected void | updateReadyStatus()
Checks & sets ready status |
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
Parameters: h Hashtable to convert
Returns: converted string array
Throws: NullPointerException if a hash key has a null value
Returns: false if not ready (run
will throw
an exception), true if ready
This implements the following CGI specification recommedations:
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.
auth-scheme
" token of the
"Authorization
" if it was supplied as part of the
request header. See getCGIEnvironment
method.
.
" and "..
" path
segments:
This implementation does not allow ".
" and
"..
" in the the path, and such characters
will result in an IOException being thrown;
Throws: IOException if problems during reading/writing occur
See Also: java.lang.Runtime#exec(String command, String[] envp,
File dir)
Parameters: stdin InputStream to be used
Parameters: response HttpServletResponse to be used