All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class w3c.jigsaw.forms.CgiResource

java.lang.Object
   |
   +----w3c.tools.store.AttributeHolder
           |
           +----w3c.tools.store.Resource
                   |
                   +----w3c.jigsaw.resources.HTTPResource
                           |
                           +----w3c.jigsaw.resources.FilteredResource
                                   |
                                   +----w3c.jigsaw.resources.FileResource
                                           |
                                           +----w3c.jigsaw.forms.CgiResource

public class CgiResource
extends FileResource
A class to handle the good old cgi scripts. This should really not be used. I am writing it for fun only, you should rather implement your own resources if you are to handle forms.

See Also:
Resource

Variable Index

 o ATTR_CGI_DEBUG
Attribute index - Turn the script in debug mode.
 o ATTR_COMMAND
Attribute index - The array of string that makes the command to run.
 o ATTR_GENERATES_FORM
Attribute index - Does the script generates the form on GET ?
 o ATTR_INTERPRETER
Attribute index - The interpreter to use, if any.
 o ATTR_NOHEADER
Attribute index - Does the script takes care of its headers ?
 o ATTR_REMOTE_HOST
Attribute index - Do DNS, to fill in REMOTE_HOST env var.

Constructor Index

 o CgiResource()

Method Index

 o checkCgiDebug()
Get the CGI debug flag.
 o checkGeneratesFormFlag()
Get the generates form flag.
 o checkNoheaderFlag()
Get the noheader flag.
 o checkRemoteHost()
Get the remote host attribute value.
 o get(Request)
GET method implementation.
 o getCommand()
Get the command string array.
 o getEnvName(String)
Turn the given header name into it's env var canonical name.
 o getInterpreter()
Get the interpreter to use to execute the script.
 o handleCGIOutput(Process, Request)
Handle the CGI script output.
 o initialize(Object[])
At init time, if no command, use a suitable default.
 o lookup(LookupState, LookupResult)
Lookup sub-resources.
 o makeCgiCommand(Request)
Prepare the command to run for this CGI script, and run it.
 o post(Request)
Handle the POST method according to CGI/1.1 specification.

Variables

 o ATTR_INTERPRETER
 protected static int ATTR_INTERPRETER
Attribute index - The interpreter to use, if any.

 o ATTR_COMMAND
 protected static int ATTR_COMMAND
Attribute index - The array of string that makes the command to run.

 o ATTR_NOHEADER
 protected static int ATTR_NOHEADER
Attribute index - Does the script takes care of its headers ?

 o ATTR_GENERATES_FORM
 protected static int ATTR_GENERATES_FORM
Attribute index - Does the script generates the form on GET ?

 o ATTR_REMOTE_HOST
 protected static int ATTR_REMOTE_HOST
Attribute index - Do DNS, to fill in REMOTE_HOST env var.

 o ATTR_CGI_DEBUG
 protected static int ATTR_CGI_DEBUG
Attribute index - Turn the script in debug mode.

Constructors

 o CgiResource
 public CgiResource()

Methods

 o getInterpreter
 public String getInterpreter()
Get the interpreter to use to execute the script. This is most usefull for operating systems that don't have a !# convention ala UNIX.

Returns:
The interpreter to run the script.
 o getCommand
 public String[] getCommand()
Get the command string array.

 o checkNoheaderFlag
 public boolean checkNoheaderFlag()
Get the noheader flag.

Returns:
The boolean value of the noheader flag.
 o checkGeneratesFormFlag
 public boolean checkGeneratesFormFlag()
Get the generates form flag.

Returns:
The boolean value of the generates form flag.
 o checkRemoteHost
 public boolean checkRemoteHost()
Get the remote host attribute value. If turned on, this flag will enable the REMOTE_HOST env var computation.

Returns:
A boolean.
 o checkCgiDebug
 public boolean checkCgiDebug()
Get the CGI debug flag.

Returns:
The boolean value of the CGI debug flag.
 o getEnvName
 public String getEnvName(String name)
Turn the given header name into it's env var canonical name. This guy is crazy enough to run CGI scripts, he can pay for that overhead.

Parameters:
name - The header name.
Returns:
A String giving the official env variable name for that header.
 o handleCGIOutput
 protected Reply handleCGIOutput(Process process,
                                 Request request) throws HTTPException
Handle the CGI script output. This methods handles the CGI script output. Depending on the value of the noheader attribute it either:

Parameters:
process - The underlying CGI process.
request - The processed request.
Throws: HTTPException
If an HTTP error should be sent back to the client.
 o makeCgiCommand
 protected Process makeCgiCommand(Request request) throws HTTPException, IOException
Prepare the command to run for this CGI script, and run it.

Parameters:
request - The request to handle.
Returns:
The running CGI process object.
Throws: HTTPException
If we weren't able to build the command or the environment.
 o lookup
 public boolean lookup(LookupState ls,
                       LookupResult lr) throws HTTPException
Lookup sub-resources. Accumulate the remaning path in some special state of the request.

This allows us to implement the PATH_INFO CGI variable properly.

Parameters:
ls - Current lookup state.
lr - Lookup result under construction.
Returns:
A boolean true if lookup should continue, false otherwise.
Overrides:
lookup in class FilteredResource
 o get
 public Reply get(Request request) throws HTTPException
GET method implementation. this method is splitted into two cases:

If the resource is able to generates its form, than run the script to emit the form. Otherwsie, use our super class (FileResource) ability to send the file that contains the form.

Note that there is no need to feed the underlying process with data in the GET case.

Parameters:
request - The request to handle.
Throws: HTTPException
If processing the request failed.
Overrides:
get in class FileResource
 o post
 public Reply post(Request request) throws HTTPException
Handle the POST method according to CGI/1.1 specification. The request body is sent back to the launched CGI script, as is, and the script output is handled by the handleCGIOutput method.

Parameters:
request - The request to process.
Throws: HTTPException
If the processing failed.
Overrides:
post in class HTTPResource
 o initialize
 public void initialize(Object values[])
At init time, if no command, use a suitable default. THis method will set the command to the identifier, if it is not provided.

Parameters:
values - Default attribute values.
Overrides:
initialize in class FileResource

All Packages  Class Hierarchy  This Package  Previous  Next  Index