Get server URL in Apex

Written by Paulo Vale on Monday, September 08, 2008

Some time ago, I had this requirement to send to the application end users, links to specific pages passing some parameters.

The problem was obtaining the full URL including the server's name and port where APEX was running.

The OWA_UTIL package contains utility subprograms for getting the value of environment variables. Specifically the OWA_UTIL.GET_CGI_ENV function returns the value of CGI environment variables, like REQUEST_PROTOCOL, HTTP_HOST, SERVER_PORT and SCRIPT_NAME, this last one to get the mod_plsql cartridge and the database access descriptor name.

Usage:



You can quickly test these values creating a PL/SQL Dynamic Content region like this:



Now to complete the URL you just need to append the well known f function with the right values. In case you have forget, here is the Apex f function URL Syntax:

Related Posts by Categories



Widget by Hoctro | Jack Book
  1. 4 comments: Responses to “ Get server URL in Apex ”

  2. By Anonymous on September 17, 2008 at 10:34 AM

    Could Apex redirect to the original URL after login? eg. a end user clicks a link "http://ip_addr/pls/apex/f?p=100:6:4477304193085910808::NO:2:P2_PRODUCT_ID:7" and the server presents a login page and then redircts to the actual page with parameters set after successful authentication.

  3. By Paulo Vale on September 17, 2008 at 11:17 AM

    Hi Anonymous,

    The answer is yes.

  4. By Anonymous on September 18, 2008 at 5:05 AM

    Hi Paulo ,

    Thank you for your reply.

    I tried that but it failed. Could you give me some hints?

    Also, I have another similar problem. when I access a url like
    "http://ip_addr/pls/appx/f?p=100:1" the browser shows me "404 page not found"
    after entering correct user/pass and I have to go back to login again to get in.
    However, if the url is "http://ip_addr/pls/appx/f?p=100:LOGIN" then it' ok and apex
    redirects to the home page(1). It appeared all right before the upgrade.

    I have a post with details at http://forums.oracle.com/forums/thread.jspa?messageID=2732475&#2732475
    That problem has puzzled me for a long time.

    Dennis

  5. By Paulo Vale on September 18, 2008 at 7:15 AM

    Dennis,

    I've just tested and it works fine.

    Have you altered the login process in your application login page? That is the only thing I can remember that could cause the problem. How do you call the wwv_flow_custom_auth_std.login procedure?

    In what concerns to your second problem, what is the Authentication Scheme (in Shared Components) you are using? Is it a custom scheme?
    Do you have the "Session Not Valid Page" option pointing to the login page?

    Paulo