2.5 Understanding URL Syntax

The URL that displays for each page identifies the location of Oracle Application Express, the address of Oracle Application Express, the application ID, the page number, and the session ID.

The application ID is a unique number that identifies each application. Similarly, the page number uniquely identifies each page within an application. Applications and pages may also have alphanumeric aliases. Application aliases are unique within a workspace and page aliases are unique within each application. When you run an application, the Application Express engine generates a session number that serves as a key to the user's session state.

Topics:

2.5.1 Understanding the URL that Displays for a Page

The URL that displays for each page indicates the location of Oracle Application Express and identifies the address of Oracle Application Express, the application ID, page number, and session ID. For example:

http://apex.somewhere.com/pls/apex/f?p=4350:1:220883407765693447

This example indicates:

  • apex.somewhere.com is the URL of the server

  • pls is the indicator to use the mod_plsql cartridge

  • apex is the database access descriptor (DAD) name. The DAD describes how HTTP Server connects to the database server so that it can fulfill an HTTP request. The default value is apex.

  • f?p= is a prefix used by Oracle Application Express

  • 4350 is the application being called

  • 1 is the page within the application to be displayed

  • 220883407765693447 is the session number

2.5.2 Using f?p Syntax to Link Pages

You can create links between pages in your application using the following syntax:

f?p=App:Page:Session:Request:Debug:ClearCache:itemNames:itemValues:PrinterFriendly

Table 2-2 describes the arguments you can pass when using f?p syntax.

Table 2-2 f?p Syntax Arguments

Syntax Description

App

Indicates an application ID or alphanumeric alias.

Page

Indicates a page number or alphanumeric alias.

Session

Identifies a session ID. You can reference a session ID to create hypertext links to other pages that maintain the same session state by passing the session number. You can reference the session ID using the syntax:

  • Short substitution string: &SESSION.

  • PL/SQL: V('SESSION')

  • Bind variable: :APP_SESSION

Request

Sets the value of REQUEST. Each application button sets the value of REQUEST to the name of the button which enables accept processing to reference the name of the button when a user clicks it. You can reference REQUEST using the syntax:

  • Substitution string: &REQUEST.

  • PL/SQL: V('REQUEST')

  • Bind variable: :REQUEST

Debug

Displays application processing details. Valid values for the DEBUG flag include:

  • YES.

  • LEVELn

  • NO

Setting this flag to YES displays details about application processing. Setting this flag to LEVELn (where n is between 1 and 9) controls the level of debug detail that displays. The value of YES equals LEVEL4.

You can reference the Debug flag using the following syntax:

  • Short substitution string: &DEBUG.

  • PL/SQL: V('DEBUG')

  • Bind variable: :DEBUG

See Also: "Debugging an Application"

ClearCache

Clears the cache. This sets the value of items to null.

To clear cached items on a single page, specify the numeric page number. To clear cached items on multiple pages, use a comma-separated list of page numbers. Clearing a page's cache also resets any stateful processes on the page. Individual or comma-separated values can also include collection names to be reset or the keyword RP, which resets region pagination on the requested page. The keyword APP clears cache for all pages and all application-level items in the current application and removes sort preferences for the current user. The keyword SESSION achieves the same result as the APP keyword, but clears items associated with all applications that have been used in the current session.

See Also: "Clearing Session State"

itemNames

Comma-delimited list of item names used to set session state with a URL.

itemValues

List of item values used to set session state within a URL. Item values cannot include colons, but can contain commas if enclosed with backslashes. To pass a comma in an item value, enclose the characters with backslashes. For example:

\123,45\

PrinterFriendly

Determines if the page is being rendered in printer friendly mode. If PrinterFriendly is set to Yes, then the page is rendered in printer friendly mode. The value of PrinterFriendly can be used in rendering conditions to remove elements such as regions from the page to optimize printed output. You can reference the printer friendly preference by using the following syntax:

V('PRINTER_FRIENDLY')

When referenced, the Application Express engine does not display tabs or navigation bars, and all items are displayed as text and not as form elements.


It is important to understand how f?p syntax works. Application Builder includes many wizards that automatically create these references for you. However, you may have to create the syntax yourself in some situations. The following sections describe specific instances that use f?p syntax to link pages.

2.5.3 Calling a Page Using an Application and Page Alias

Application and page aliases must consist of valid Oracle identifiers, cannot contain any whitespace, and are not case-sensitive. The following example calls a page using an application and a page alias from within an application. It runs the page home of the application myapp and uses the current session ID.

f?p=myapp:home:&APP_SESSION.

Application aliases must be unique within a workspace. If an application in a different workspace has the same application alias, use the &c argument to specify the workspace name. For example:

f?p=common_alias:home:&APP_SESSION.&c=WORKSPACE_A

2.5.4 Calling a Page from a Button URL

When you create a button, you can specify a URL to redirect to when the user clicks the button. This example runs page 6001 of application 6000 and uses the current session ID.

f?p=6000:6001:&APP_SESSION.

Note that this is only one approach to using a button. This method bypasses page submission and acts as a hyperlink on the page. You can also have a button click submit a page. In that approach, clicking the button submits the page for processing, allowing forms to be submitted and session state to be saved.

2.5.5 Facilitating Bookmarks by Using Zero as the Session ID

If the pages within an application are public and do not require authentication, you help application users to bookmark pages by using zero as the session ID.

Application pages that do not require authentication can be accessed with "f?p" URLs where the session ID is zero (that is, the single digit 0). When you request a page by either entering the URL in the browser or by clicking on a link having 0 for the session ID, the Application Express engine assigns a new session ID and sends a session cookie containing this new session ID to your browser. As you navigate through the application's public pages, you see that all generated links to public pages contain 0 for the session ID and all branches to public pages have new URLs that use 0 as the visible session ID. Behind the scenes, however, the Application Express engine uses the session ID in the cookie as the actual session ID to locate session state.

This feature is useful when you want to hide the actual session ID. By hiding the session ID, you enable users to bookmark pages without needing to include the session ID in the bookmark link. As an added benefit, using zero as the session ID also keeps the actual session ID hidden from search engines.

To use zero as the session ID in your application, must generate at least one link having a zero session ID. The use of this first link starts the zero session ID mechanism. One approach would be to provide a single static link with a zero session ID on the application home page. For example, where you might normally code the link to page 2 as f?p=&APP_ID.:2:&APP_SESSION, you would code f?p=&APP_ID.:2:0.

2.5.5.1 About APEX_UTIL.PREPARE_URL

Oracle provides a utility function to enable developers to use PL/SQL to generate anchors to application pages using the f?p syntax. Use APEX_UTIL.PREPARE_URL whenever PL/SQL in the application produces f?p anchors that might require a zero session ID. To learn more, see "PREPARE_URL" in Oracle Application Express API Reference.

2.5.5.2 How the Zero Session ID Feature Works

The zero session ID feature provides support for pages having anchors in the HTML (such as in templates or HTML regions). When the Application Express engine encounters f?p anchors it recognizes them and replaces the session ID with zero, if certain criteria are met.

The Application Express engine replaces the session ID component with zero when it detects the following situations:

  • The numeric ID of the current application

  • One of the following patterns:

    • the all-uppercase or all-lowercase alphanumeric alias of the current application followed by a colon followed by the numeric ID of a public page in the current application

    • the all-uppercase or all-lowercase alphanumeric alias of a public page in the current application followed by a colon followed by &APP_SESSION. or &SESSION.

Examples of patterns in HTML that are candidates for zero-session ID replacement include:

  • Page 10 is a public page:

    "f?p=&APP_ID.:10:&APP_SESSION. 
    
  • Page 10 is a public page:

    "f?p=100:10:&APP_SESSION.
    
  • home is an alias for a public page:

    "f?p=&APP_ID.:home:&APP_SESSION. 
    
  • HOME is an alias for a public page:

    "f?p=&APP_ID.:HOME:&APP_SESSION.
    
  • PEOPLE is an application alias and HOME is an alias for a public page:

    "f?p=PEOPLE:HOME:&APP_SESSION
    

In these examples, the pattern &APP_SESSION. (or &SESSION., not shown) is replaced with zero if the application is operating in zero-session ID mode and the user is a public user. Note that the user is considered a public user if the following PL/SQL expression is true:

:app_user in ('nobody','HTMLDB_PUBLIC_USER','PUBLIC_USER','ANONYMOUS','APEX_PUBLIC_USER')" 

Tip:

For links not prepared by the Application Express engine, use the built-in substitution APP_SESSION_VISIBLE which returns '0' for the session ID when a user is not authenticated to an application and they are using the zero-session ID feature of Oracle Application Express. See "APP_SESSION_VISIBLE".