Wednesday, January 7, 2009

Redirection Process Follow Up

It seems there are a few undocumented features you can add to the mix to get the redirect to work more efficiently. I'm lead to believe that htp.init clears any headers that may have been set previously and setting apex_application.g_unrecoverable_error to true will tell APEX to stop processing the page after the redirect process is complete. Though both are not officially documented, there is a comment in the package next to apex_application.g_unrecoverable_error that reads:
indicates error has occured which requires error page

So here's what I'm using now:

htp.init;
owa_util.redirect_url('f?p='||:APP_ID||':XYZ:'||:APP_SESSION||'::'||:DEBUG||':::');
owa_util.http_header_close;
apex_application.g_unrecoverable_error := true;

According to the doco, this should result in the following raw HTTP response where <curl> is the resultant url:
Location: <curl>\n\n

Here's some references:
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/w_util.htm
http://www.psoug.org/reference/htp.html
http://download.oracle.com/docs/cd/B28359_01/appdev.111/b28419/w_htp.htm
http://www.google.com/search?q=apex_application.g_unrecoverable_error

Update: After inspecting the response, seems we don't need to explicitly close headers.
Update: See my post about HTTP Headers for more details about htp.init behaviour.

No comments: