Parsing   Browser   URLs     
          Parsing the Web Browser URL  






One of the problems with Answers and Dashboards is that some HTML elements are generated dynamically during Presentation Services processing.  These elements are allocated arbitrary names or identifiers, and we have no control over the generation process.  In order to create the desired OBIEE functionality sometimes we need to make use of these dynamically generated elements.  But because they are dynamic, we can’t code static values into requests and dashboards during development.  Instead, we have to dynamically parse out these elements at runtime, as and when required. 


There are two sources of dynamic content: the web page and the browser URL.  In the case of web page content, we can use the HTML DOM model to parse HTML elements (see the article entitled “Pivot Table Formatting – Javascript & HTML DOM” for an example).  In this article we’re going to tackle the much simpler requirement of parsing elements out from the web browser URL.





Let’s start off with a sample URL:

Raw SQL Window URL


This URL opens up the Answers window used to issue raw SQL and makes a call to ODBC function “NQSSetSessionValue” to assign the value “Value1” to session variable “SN_TEST”.


The dynamically generated element in this browser URL is the “scid” assignment:




If we try to use a URL without including the “scid” element:

URL without SCID Element


then we get an error:

Access Error


If we try to replace the “scid” element with the user name and password:

    URL with Username and Password Elements


then we still get the same access error.


So if we want to issue raw SQL programmatically then we must extract the context value for the “scid” from the current browser URL and then dynamically create a new URL containing this “scid” in order to access the raw SQL window.


The other element in this URL that we may need to extract is the URL prefix that contains the machine name, “hp”, and the port, “9704”:

URL Prefix


While we can usually use prefix abbreviations, such as




or just




depending on the context, there are occasions when the full prefix is required, so it would also be useful to be able to parse the full prefix out from the context URL.



Referencing the URL


To access the full URL from Javascript we can use the document reference:




To verify that this reference works correctly we can make a Javascript reference from within a dashboard text object:

URL Ouput using Javascript



Parsing the URL


To parse elements out of the URL we can use the REX engine that’s built into the Javascript processor.  The “match” method takes a regular expression as an argument and searches the associated object for a matching text string. 


A Javascript call of:

SCID Element Extraction


correctly extracts the “scid” element:

Extracted SCID


The REX engine starts searching at the first occurrence in the text of:




The notation “[^&]” means any character not equal to “&”, and the “+” that follows means “one or more characters”.  So the search terminates when the next occurrence of character “&” is found.


A Javascript call of:

URL Prefix Extraction


correctly extracts the URL prefix:

Extracted URL Prefix


The REX engine starts searching at the beginning of the string, denoted by the leading character “^”.  As before, the notation “[^?]” means any character not equal to “?”, and the “+” that follows means “one or more characters”.  So the search terminates when the next occurrence of character “?” is found.


Once these dynamic elements have been extracted, then they can be concatenated with other fixed elements to form the desired URL, and to embed the URL within a pair of “a” or “iframe” tags, as appropriate.