protected class CGIServlet.CGIRunner
extends java.lang.Object
Exposes a run method used to actually invoke the CGI.
The CGI environment and settings are derived from the information passed to the constructor.
The input and output streams can be set by the setInput and setResponse methods,
respectively.
| Modifier | Constructor and Description |
|---|---|
protected |
CGIRunner(java.lang.String command,
java.util.Hashtable<java.lang.String,java.lang.String> env,
java.io.File wd,
java.util.ArrayList<java.lang.String> params)
Creates a CGIRunner and initializes its environment, working directory, and query parameters.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String[] |
hashToStringArray(java.util.Hashtable<java.lang.String,?> 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 recommendations:
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(HttpServletResponse response)
Sets HttpServletResponse object used to set headers and send output to
|
protected void |
updateReadyStatus()
Checks and sets ready status
|
protected CGIRunner(java.lang.String command,
java.util.Hashtable<java.lang.String,java.lang.String> env,
java.io.File wd,
java.util.ArrayList<java.lang.String> params)
setInput and setResponse methods,
respectively.command - string full path to command to be executedenv - Hashtable with the desired script environmentwd - File with the script's desired working directoryparams - ArrayList with the script's query command line parameters as stringsprotected void updateReadyStatus()
protected boolean isReady()
run will throw an exception), true if readyprotected void setResponse(HttpServletResponse response)
response - HttpServletResponse to be usedprotected void setInput(java.io.InputStream stdin)
stdin - InputStream to be usedprotected java.lang.String[] hashToStringArray(java.util.Hashtable<java.lang.String,?> h)
throws java.lang.NullPointerException
h - Hashtable to convertjava.lang.NullPointerException - if a hash key has a null valueprotected void run()
throws java.io.IOException
This implements the following CGI specification recommendations:
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 (this should never happen since Tomcat normalises the requestURI before determining the
contextPath, servletPath and pathInfo);
java.io.IOException - if problems during reading/writing occurRuntime.exec(String command, String[] envp, File dir)Copyright © 2000-2024 Apache Software Foundation.
Apache Tomcat, Tomcat, Apache, the Apache Tomcat logo and the Apache logo are either registered trademarks or trademarks of the Apache Software Foundation.