public abstract class CGI extends Object
| Constructor | Description |
|---|---|
CGI() |
| Modifier and Type | Method | 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.
|
OutputStream |
getOutputStream() |
This will return an OutputStream that you can write data
directly to.
|
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.
|
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.
|
protected void |
setErrorHandler(CGIErrorHandler handler) |
Sets a custom exception handler.
|
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.public final void doCGI(String[] args)