public class ScriptEnvironment
extends java.lang.Object
| Constructor and Description |
|---|
ScriptEnvironment(HttpServletRequest req,
ServletContext context,
java.lang.String scriptPathPrefix)
Creates a CGIEnvironment and derives the necessary environment,
query parameters, working directory, cgi command, etc.
|
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
blanksToString(java.lang.String couldBeBlank,
java.lang.String subForBlanks)
Converts blank strings to another string
|
protected void |
expandScript()
Extracts requested resource from web app archive to context work
directory to enable script to be executed.
|
protected java.lang.String[] |
findScript(java.lang.String pathInfo,
java.lang.String webAppRootDir,
java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String scriptPathPrefix)
Resolves core information about the php script.
|
java.util.Hashtable |
getEnvironment()
Gets derived Script environment
|
java.lang.String[] |
getEnvironmentArray()
Converts Environment Hastable to String array
|
java.lang.String |
getFullPath()
Gets derived script full path
|
java.util.ArrayList |
getParameters()
Gets derived Script query parameters
|
java.io.File |
getScriptFile()
Gets derived Script file
|
java.io.File |
getWorkingDirectory()
Gets derived Script working directory
|
static 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 two consecutive Strings
|
boolean |
isValid()
Gets validity status
|
protected java.lang.String |
nullsToBlanks(java.lang.String s)
Converts null strings to blank strings ("")
|
protected java.lang.String |
nullsToString(java.lang.String couldBeNull,
java.lang.String subForNulls)
Converts null strings to another string
|
protected boolean |
setEnvironment(HttpServletRequest req)
Constructs the CGI environment to be supplied to the invoked CGI
script; relies heavliy on Servlet API methods and findCGI
|
public ScriptEnvironment(HttpServletRequest req,
ServletContext context,
java.lang.String scriptPathPrefix)
throws java.io.IOException
req - HttpServletRequest for information provided by
the Servlet APIcontext - ServletContext for information provided by the
Servlet APIjava.io.IOExceptionprotected java.lang.String[] findScript(java.lang.String pathInfo,
java.lang.String webAppRootDir,
java.lang.String contextPath,
java.lang.String servletPath,
java.lang.String scriptPathPrefix)
Example URI:
/servlet/scriptGateway/dir1/realScript/pathinfo1
path = $CATALINA_HOME/mywebapp/dir1/realScript
scriptName = /servlet/scriptGateway/dir1/realScript
fullName = /dir1/realScript
name = realScript
Script search algorithm: search the real path below <my-webapp-root> and find the first non-directory in the getPathTranslated("/"), reading/searching from left-to-right.
The Script search path will start at webAppRootDir + File.separator + scriptPathPrefix (or webAppRootDir alone if scriptPathPrefix is null).
scriptPathPrefix is defined by setting this servlet's scriptPathPrefix init parameter
pathInfo - String from HttpServletRequest.getPathInfo()webAppRootDir - String from context.getRealPath("/")contextPath - String as from
HttpServletRequest.getContextPath()servletPath - String as from
HttpServletRequest.getServletPath()scriptPathPrefix - Subdirectory of webAppRootDir below which
the web app's Scripts may be stored; can be null.
The Script search path will start at
webAppRootDir + File.separator + scriptPathPrefix
(or webAppRootDir alone if scriptPathPrefix is
null). scriptPathPrefix is defined by setting
the servlet's scriptPathPrefix init parameter.path - full file-system path to valid script file,
or null if no script file was found
scriptName -
Script variable SCRIPT_NAME; the full URL path
to valid script file or null if no script was
found
fullName - servlet pathInfo fragment corresponding to
the script itself, or null if not found
name - simple name (no directories) of the
script, or null if no script was found
protected void expandScript()
protected boolean setEnvironment(HttpServletRequest req)
throws java.io.IOException
req - request associated with the CGI
invokationjava.io.IOExceptionpublic java.lang.String getFullPath()
public java.io.File getScriptFile()
public java.io.File getWorkingDirectory()
public java.util.Hashtable getEnvironment()
public java.util.ArrayList getParameters()
public boolean isValid()
protected java.lang.String nullsToBlanks(java.lang.String s)
s - string to be converted if necessarynullprotected java.lang.String nullsToString(java.lang.String couldBeNull,
java.lang.String subForNulls)
couldBeNull - string to be converted if necessarysubForNulls - string to return instead of a null stringnullprotected java.lang.String blanksToString(java.lang.String couldBeBlank,
java.lang.String subForBlanks)
couldBeBlank - string to be converted if necessarysubForBlanks - string to return instead of a blank stringnull or empty ("")public java.lang.String[] getEnvironmentArray()
throws java.lang.NullPointerException
java.lang.NullPointerException - if a hash key has a null valuepublic static java.lang.String[] hashToStringArray(java.util.Hashtable h)
throws java.lang.NullPointerException
h - Hashtable to convertjava.lang.NullPointerException - if a hash key has a null value