|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
com.ibm.wbi.Meg
|
+--com.ibm.wbi.Generator
|
+--com.ibm.wbi.protocol.http.HttpGenerator
|
+--com.ibm.wbi.protocol.http.beans.FourStepHttpGenerator
|
+--com.ibm.wbi.protocol.http.beans.ErrorPageGenerator
A Generator for producing an HTTP response that corresponds to an error condition. It is designed to work in conjunction with the ErrorPageException class. Typically, the programmer will write a Generator with a try block around code where an error condition could occur. When the error is detected, an ErrorPageException object should be constructed and thrown. The catch block would then construct an ErrorPageGenerator from the ErrorPageException and forward the original RequestEvent to it for handling. The ErrorPageGenerator will then produce the appropriate response.
For example:
public void handleRequest(RequestEvent e) {
try {
... determine if error has occurred ...
if (error) throw new ErrorPageException(404, "URL does not exist");
.. do other stuff ...
} catch (ErrorPageException epe) {
forwardRequest(new ErrorPageGenerator(epe), e);
}
}
There are three properties that can be set: ResponseCode, ResponseText, and PageText. The ResponseCode is the HTTP code that will be in the HTTP response. The ResponseText is the short message that is part of the HTTP response. The PageText is the HTML that accompanies the HTTP response.
ErrorPageException| Field Summary | |
static java.lang.String |
COPYRIGHT
IBM copyright information |
protected java.lang.String |
pageText
The page text. |
| Fields inherited from class com.ibm.wbi.protocol.http.HttpGenerator |
http |
| Fields inherited from class com.ibm.wbi.Meg |
EDITOR, GENERATOR, MONITOR, REQUEST_EDITOR, UNDEFINED |
| Constructor Summary | |
ErrorPageGenerator()
Construct an instance with a ResponseCode of 400, a ResponseText of "Unknown Error", and a PageText of "". |
|
ErrorPageGenerator(ErrorPageException e)
Construct an instance from the information in the ErrorPageException. |
|
| Method Summary | |
protected java.lang.String |
getHeader(RequestEvent e)
Get the header. |
java.lang.String |
getPageText()
Access the PageText property. |
int |
getResponseCode()
Access the ResponseCode property. |
java.lang.String |
getResponseText()
Access the ResponseText property. |
void |
setPageText(java.lang.String pt)
Set the PageText property. |
void |
setResponseCode(int rc)
Set the ResponseCode property. |
void |
setResponseText(java.lang.String rt)
Set the ResponseText property. |
protected void |
writeContent(RequestEvent e)
Write the content to the output stream. |
| Methods inherited from class com.ibm.wbi.protocol.http.beans.FourStepHttpGenerator |
handleRequest, initialize, verify |
| Methods inherited from class com.ibm.wbi.protocol.http.HttpGenerator |
add, addCookie, getContentType, getHttpResponse, getHttpResponseString, isCache, produceHeader, set, setCache, setContentLength, setContentType, setServer, writeHeader |
| Methods inherited from class com.ibm.wbi.Generator |
getType |
| Methods inherited from class com.ibm.wbi.Meg |
forwardRequest, getCondition, getEnabled, getMegProperty, getMegProperty, getMegPropertyKeys, getName, getPlugin, getPriority, getSystemContext, initialize, initialize, isEnabled, isMegApplicable, loadMegResources, run, setCondition, setEnabled, setMegProperty, setName, setPriority, setSystemContext, setup, setup, setup, setup |
| Field Detail |
public static final java.lang.String COPYRIGHT
protected java.lang.String pageText
| Constructor Detail |
public ErrorPageGenerator()
public ErrorPageGenerator(ErrorPageException e)
e - The exception which indicates the type and cause of the
error.| Method Detail |
public void setPageText(java.lang.String pt)
pt - The HTML that will be passed back to the browser for
display.public java.lang.String getPageText()
public void setResponseCode(int rc)
setResponseCode in class HttpGeneratorrc - The HTTP response code that will be passed back to the
browser (e.g. 200, meaning "Ok").public int getResponseCode()
getResponseCode in class HttpGeneratorpublic void setResponseText(java.lang.String rt)
setResponseText in class HttpGeneratorrt - The response text that accompanies the HTTP response
(e.g. "Ok").public java.lang.String getResponseText()
getResponseText in class HttpGeneratorprotected java.lang.String getHeader(RequestEvent e)
getHeader in class FourStepHttpGeneratore - The request event,
protected void writeContent(RequestEvent e)
throws java.io.IOException
writeContent in class FourStepHttpGeneratore - The request event.java.io.IOException - If an error occurs.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||