Consultor Eletrônico



Kbase P125848: How to replace WebSpeed message 'Unable to find web object file...' with custom web page
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   9/12/2007
Status: Unverified

GOAL:

How to replace WebSpeed message 'Unable to find web object file...' with custom web page

FACT(s) (Environment):

WebSpeed 3.1E
OpenEdge 10.1A
OpenEdge 10.1B

FIX:

In order to replace the WebSpeed message 'Unable to find web object file...' with the
customized html page, redirect to some other page, or setting the response status
to '404 Object Not Found', follow the steps:
1. In the WebSpeed broker properties, 'Environment Variables' section add the following:
[Environment.wsbroker1]
ERROR_PROC=my404.p
SUPER_PROC=setErrorProc.p
Replace the reference to the wsbroker1 with adequate broker name.
my404.p should be changed with the procedure name that renders the custom html page,
does the redirect to another page, or otherwise sets the http 'Status' header to '404 Object Not Found'.
2. Create the setErrorProc.p procedure with the following content:
/* setErrorProc.p */
{src/web/METHOD/cgidefs.i}
DEFINE VARIABLE cErrorProc AS CHARACTER NO-UNDO.
ASSIGN cErrorProc = OS-GETENV("ERROR_PROC":U).
IF SEARCH(cErrorProc) <> ? AND SEARCH(cErrorProc) <> "" THEN
DYNAMIC-FUNCTION("setAgentSetting" IN web-utilities-hdl,"Misc":U,"","ErrorProc":U,cErrorProc).
DELETE PROCEDURE THIS-PROCEDURE .
/* end of procedure setErrorProc.p */

3. Create the procedure specific in ERROR_PROC that sets the customized response, for example:
/* my404.p */
CREATE WIDGET-POOL.
DEFINE INPUT PARAMETER cErrorMsg AS CHARACTER NO-UNDO.
{ src/web/method/cgidefs.i }
/* If requested URL doesn't exist then redirect to 404, else output the error message(s) */
IF cErrorMsg BEGINS "Unable to find" THEN
DO:
output-http-header("Status", "404 Object Not Found").
output-http-header("","").
output-content-type ("text/html":U).
END.
ELSE
DO:
output-content-type ("text/html":U).
{&OUT}
"<HTML>":U SKIP
"<HEAD>":U SKIP
"<TITLE> {&FILE-NAME} </TITLE>":U SKIP
"</HEAD>":U SKIP
"<BODY>":U SKIP
.

/* Output your custom HTML and/or error messages to WEBSTREAM here (using {&OUT}). */

{&OUT} "<BR>" cErrorMsg "<BR>" SKIP
"</BODY>":U SKIP
"</HTML>":U SKIP
.
END.
/* end of procedure my404.p */

Instead of this sample code, any valid cgi wrapper, or SpeedScript procedure can be used,
but it must accept one input parameter of the character data type.
4. Place these two procedures in the WebSpeed agent PROPATH so that they could be found
and restart the WebSpeed broker. Test your configuration using the non-existent procedure
or html file in the URL and confirm that customized page/response is working.