42.91 PREPARE_URL Function
Note:
Oracle recommends using APEX_PAGE.GET_URL
instead of PREPARE_URL
for improved readability.
See GET_URL Function.
The PREPARE_URL function serves two purposes:
-
To return an Application Express navigation URL with the Session State Protection checksum argument (&cs=) if one is required. For security, the URL will not contain a checksum if the specified application is located in a different workspace.
-
To return an Application Express navigation URL with the session ID component replaced with zero (0) if the zero session ID feature is in use and other criteria are met.
Note:
The PREPARE_URL
function returns the Application Express navigation URL with &cs=<large hex value>
appended. If you use this returned value (such as in JavaScript), you may need to escape the ampersand in the URL to conform with syntax rules of the particular context.
Syntax
APEX_UTIL.PREPARE_URL (
p_url IN VARCHAR2,
p_url_charset IN VARCHAR2 default null,
p_checksum_type IN VARCHAR2 default null,
p_triggering_element IN VARCHAR2 default 'this'
p_plain_url IN BOOLEAN default false
RETURN VARCHAR2;
Parameters
Table 42-75 PREPARE_URL Parameters
Parameter | Description |
---|---|
|
An Application Express navigation URL with all substitutions resolved. |
|
The character set name (for example, |
|
Null or any of the following values:
|
|
A jQuery selector (for example, |
|
If the page you are calling |
Example 1
The following example shows how to use the PREPARE_URL
function to return a URL with a valid 'SESSION' level checksum argument. This URL sets the value of P1_ITEM
page item to xyz
.
DECLARE
l_url varchar2(2000);
l_app number := v('APP_ID');
l_session number := v('APP_SESSION');
BEGIN
l_url := APEX_UTIL.PREPARE_URL(
p_url => 'f?p=' || l_app || ':1:'||l_session||'::NO::P1_ITEM:xyz',
p_checksum_type => 'SESSION');
END;
Example 2
The following example shows how to use the PREPARE_URL
function to return a URL with a zero session ID. In a PL/SQL Dynamic Content region that generates f?p
URLs (anchors), call PREPARE_URL
to ensure that the session ID is set to zero when the zero session ID feature is in use, when the user is a public user (not authenticated), and when the target page is a public page in the current application:
htp.p(APEX_UTIL.PREPARE_URL(p_url => 'f?p=' || :APP_ID || ':10:'|| :APP_SESSION
||'::NO::P10_ITEM:ABC');
When using PREPARE_URL
for this purpose, the p_url_charset
and p_checksum_type
arguments can be omitted. However, it is permissible to use them when both the Session State Protection and Zero Session ID features are applicable.
See Also:
About Enabling Support for Bookmarks in Oracle Application Express App Builder User’s Guide.
Parent topic: APEX_UTIL