+

Search Tips   |   Advanced Search

Portal, V6.1


 

How the rules engine works

The rules engine processes and delivers the results of a rule execution to a content spot contained in a Web page. The content spot is marked by a
content spot bean which is placed in either a JSP file or a servlet. The JSP file or servlet is then linked to the Web page.

At run-time, the content spot bean searches for the best rule to fill the spot with personalized data. The best rule to use depends on the campaigns that have been set up to execute. The rule mapped to the content spot in the campaign with the highest priority will be executed to personalize your Web page.

Rule processing results in the return of a set of resources or a profiler. The returned resources or profiler can be used for generating a partial or entire Web page. The figure illustrates how a rule is processed.

Step A: The process begins when a user requests a Java Server Page (JSP) or servlet in which a content spot bean has been embedded. The content spot bean contains the code to find and execute the rule. When the Web server receives the client request for the JSP or servlet, the Web server passes the JSP or servlet request to the IBM WebSphere Application Server, which then invokes its JSP or servlet processor. The content spot bean can be embedded in the JSP using any JSP editor. The example code below demonstrates embedding and using a content spot bean in a JSP.

IBM Rational Application Developer provides a visual JSP editor (Page Designer) that simplifies the development task and generates the JSP scriptlet coding for you.

The bean is embedded using the JSP useBean tag. The HTTPServletRequest object is passed to the bean within the body of the useBean tag. The content spot bean properties are retrieved in the same manner as retrieving properties for any JavaBean. The getRuleContent method of the contactsByLocation content spot bean determines the appropriate rule to execute based on campaigns having a rule mapped to the spot, executes the rule, and returns the results. The bean returns an array of Personnel objects.

 <jsp:useBean id=“contactsByLocation” class=“GetContactsByLocation”>
 <% contactsByLocation.setRequest(request); %>
 </jsp:useBean>
 <%
 try {

Personnel[] contentArray = contactsByLocation.getRuleContent();

Personnel theContent = contentArray[0]; // throws an exception if empty %> <TABLE border=“1”> <TBODY> <TR> <TD>Last Name</TD> <TD>First Name</TD> <TD>Role</TD> <TD>Site</TD> </TR> <% for (int _i0 = 0; ; ) { %> <TR> <TD><%= theContent.getLastName() %></TD> <TD><%= theContent.getFirstName() %></TD> <TD><%= theContent.getRole() %></TD> <TD><%= theContent.getSite() %></TD> </TR> <% _i0++; try { theContent = contentArray[_i0]; } catch (java.lang.ArrayIndexOutOfBoundsException _e0) { break; } } %> </TBODY> </TABLE> <% } catch (java.lang.ArrayIndexOutOfBoundsException _e0) { } %>

When deciding to add personalized content to a Web page, all that is needed to develop the JSP is the content spot bean. The content spot can display personalized data of a single data type

For example...

Personnel in the above example). The Web developer does not need to know where or how the content is retrieved, only that personalized content of type Personnel will be returned and it will have a set of properties to be displayed.

Step B: When the embedded content spot bean is invoked, the processor passes the HTTP servlet request object to the content spot bean. The client request is used to initialize the RequestContext. The RequestContext provides access to the resources needed for rule processing. Those resources include collections, application objects, requests, and sessions. The RequestContext is applicable for the life of the HTTP request.

Step C: The Personalization rules engine find the appropriate rules in the IBM Java Content Repository and executes them

Step D: The rules engine processes the rule to obtain the results of the rules execution.

Step E: The rules engine returns the result of the rule execution to the content spot bean. The result can be a list of valid content from which a user can make a selection, a string, a boolean value, or no results. The JSP scriptlet or servlet uses the rule result to derive specific Web content for use in the generated Web page. The Web server forwards the page to the client.

 

Parent topic

Personalization programming reference