| Modifier and Type | Field and Description |
|---|---|
private Vector |
cookies |
private CGIErrorHandler |
errorhandler |
private HashMap |
headers |
private boolean |
headers_sent |
private LinkedList |
pagedata |
private LinkedList |
rawdata |
| Constructor and Description |
|---|
CGI() |
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
cgi(Map POST,
Map GET,
Map ENV,
Map COOKIES,
String[] params)
Override this method in your CGI program.
|
void |
doCGI(String[] args)
This method sets up all the CGI variables and calls the cgi() method, then writes out the page data.
|
void |
flush()
Flushes the output.
|
private Map |
getCOOKIE()
Sets up the COOKIEs
|
private Map |
getENV()
Sets up the ENV variables
|
private String |
getenv(String var) |
private Object[] |
getfullenv(Class c)
MUST pass String.class and ALWAYS returns a String[]
|
private Map |
getGET()
Sets up the GET variables
|
OutputStream |
getOutputStream()
This will return an OutputStream that you can write data
directly to.
|
private String[] |
getParams(String args)
Sets up the param variables
|
private Map |
getPOST()
Sets up the POST variables
|
void |
header(String variable,
String value)
Called by CGIs to send a header to the output
|
void |
out(byte[] data)
Called by CGIs to send byte data to the output.
|
void |
out(String data)
Called by CGIs to send a string to the output.
|
private Object |
readVariables(String s,
char seperator,
boolean values)
Reads variables from a String like a=b&c=d to a Map {a => b, c => d}.
|
void |
setcookie(String variable,
String value)
Sets a Cookie in the web browser.
|
void |
setcookie(String variable,
String value,
String path,
String domain,
Date expires,
boolean secure)
Sets a Cookie in the web browser, with extended attributes.
|
private void |
setenv(String var,
String value) |
protected void |
setErrorHandler(CGIErrorHandler handler)
Sets a custom exception handler.
|
private CGIErrorHandler errorhandler
private boolean headers_sent
private HashMap headers
private Vector cookies
private LinkedList pagedata
private LinkedList rawdata
private Object[] getfullenv(Class c)
public final void header(String variable, String value) throws CGIHeaderSentException
variable - The header variable to set.value - The value of the variable.CGIHeaderSentException - if the headers have already been sent.flush()public final void setcookie(String variable, String value, String path, String domain, Date expires, boolean secure) throws CGIHeaderSentException
variable - The cookie variable to set.value - The value of the variable.path - The path that the cookie will be returned for.domain - The domain that the cookie will be returned for.expires - The expiry date of the cookie.secure - Will only send the cookie over HTTPS if this is true.CGIHeaderSentException - if the headers have already been sent.flush(),
header(java.lang.String, java.lang.String)public final void setcookie(String variable, String value) throws CGIHeaderSentException
variable - The cookie variable to set.value - The value of the variable.CGIHeaderSentException - if the headers have already been sent.flush(),
header(java.lang.String, java.lang.String)public final void out(byte[] data)
throws CGIInvalidContentFormatException
data - The page data.CGIInvalidContentFormatException - if text data has already been sent.flush()public final void out(String data) throws CGIInvalidContentFormatException
data - The page data.CGIInvalidContentFormatException - if raw data has already been sent.flush()public final OutputStream getOutputStream() throws IOException
IOExceptionout(byte[])public final void flush()
throws IOException
IOExceptionheader(java.lang.String, java.lang.String)protected final void setErrorHandler(CGIErrorHandler handler)
handler - The new exception handlerprotected abstract void cgi(Map POST, Map GET, Map ENV, Map COOKIES, String[] params) throws Exception
POST - A Map of variable =$gt; value for the POST variables.GET - A Map of variable =$gt; value for the GET variables.ENV - A Map of variable =$gt; value for the Webserver environment variables.COOKIES - A Map of variable =$gt; value for the browser-sent cookies.params - An array of parameters passed to the CGI (GET with no variable assignments)Exception - You can throw anything, it will be caught by the error handler.private Object readVariables(String s, char seperator, boolean values)
s - String to read from.seperator - seperator character between variables (eg &)values - whether or not this string has values for variablesprivate Map getPOST()
private Map getCOOKIE()
private Map getGET()
private Map getENV()
public final void doCGI(String[] args)
Copyright © 2015. All Rights Reserved.