The example JSP that follows processes Business Object XI
pages. The JSP processes page content and returns any variables
(OPCGIPARAMs) for future processing during CCL playback. It is designed
to process Business Objects XI HTTP requests and determine the correct sEntry/logonToken
values.
It takes a vector of page contents and processes each one in turn. When finished it places on the request object an attribute named 'variables' that contains any OPCGIPARAM variables that have been set as a result of the processing.
The request attribute “url” contains the URL that was requested that triggered the page loads. The request attribute “content” is a vector of content objects, for each page that was loaded as a result of the target being requested.
See the notes following the code for more information.
<%-- This JSP processes page content and returns any variables (OPCGIPARAMs) for future processing during CCL playback. It is designed to process BO XI HTTP requests and determine the correct sEntry/logonToken values. ... This processing will only work for BO XI. --%> <%@ page import="java.util.*" %> <%@ page import="java.io.*" %>
% boolean debug = false; String targeturl = (String)request.getAttribute("url"); Vector content = (Vector)request.getAttribute("content"); if (debug) System.out.println("=======================\n\ntarget url: " + targeturl); // we don't process any URL that isn't directed at the BO XI server if (targeturl.indexOf("/businessobjects/enterprise11/") == -1) return; Hashtable vars = new Hashtable(); for (int i = 0; i < content.size(); i++) { // Each content item is a Properties object // The 'url' property contains the URL for the content // The 'html' property contains the HTML page content Properties pageInfo = (Properties)content.elementAt(i); String urlStr = pageInfo.getProperty("url"); String html = pageInfo.getProperty("html"); if (debug) System.out.println("JSP: url: " + urlStr); if (urlStr.indexOf("/InfoView/listing/reportList.do") != -1) {
int idx = html.indexOf("return finalUrl + \"logonToken="); if (idx == -1) { if (debug) System.out.println("No logonToken ..."); continue; } int endIdx = html.indexOf("\"", idx+30); String logonToken = html.substring(idx+30, endIdx); if (debug) System.out.println("JSP: logonToken: " + logonToken); Hashtable urlVars = new Hashtable(); urlVars.put("logonToken", logonToken); vars.put(urlStr, urlVars); }
else if (urlStr.indexOf("/viewers/cdz_adv/viewCDZDocument.jsp") != -1) { int idx = html.indexOf("writeBody(\"report.jsp?sEntry="); if (idx == -1) { if (debug) System.out.println("No strEntry ..."); continue; } int endIdx = html.indexOf("&", idx+29); String strEntry = html.substring(idx+29, endIdx); if (debug) System.out.println("JSP: sEntry: " + strEntry); Hashtable urlVars = new Hashtable(); urlVars.put("sEntry", strEntry); vars.put(urlStr, urlVars); } } request.setAttribute("variables", vars); %>
The main things to note are the input request attributes “url” and “content,” and the output request attribute “'variables.”
Input request attributes
“url” is a String used to tell the JSP what the URL requested during this step was.
“content” is a Vector or objects, describing all the HTML pages that were returned as a result of requesting this URL (there may be multiple pages). Each object in the Vector is a Java Properties object, containing a “url” and “html” property. The “url” property contains the actual URL of the content; “html” contains the HTML as a Java String. The JSP is responsible for parsing the HTML as it thinks fit, and extracting any values that will be useful as OPCGIPARAM key pairs.
Output request attribute
On exit, the JSP should set the attribute “variables.” This
is a Java Hashtable, that is keyed on urls – each URL would
key another Hashtable, which contains the name/value
pairs
that have been determined for that URL.
When UA saves the name/value
pairs,
it does so under two keys: the simple name, and a key constructed
from the URL the name was seen under and the name, as <url>:<name>
.
For example;
http://www.company.com/path:sEntry
In this example, the URL is http://www.company.com/path
,
and the OPCGIPARAM key is sEntry
.
This allows developers to decide whether OPCGIPARAMs are sensitive
to URLs or generic across all URLs.
Note that the URL saved is always saved without any
query parameters.
The Page Content Processor JSP is executed during web element runtime, such that after each HTTP get or post is recorded in the CCL, and submitted by UA, we call the JSP and present it with the returned HTML page content (as described above).