Coding the portlet JSP
Use the RAD Project Explorer to work with...
- pers_offers.Pzn_offersSpot.class
- pers_offers.Per_Offers_UserSpot.class
Define the context parameters offersSpot and the userSpot. Code the setRequest calls to pass the user context to personalization.
- From the Rational Application Developer Project Explorer, open...
PersOffers/WebContent/pers_offers/jsp/html/Pers_OffersPortletView.jsp
- Drag the pers_offers.Pzn_offersSpot.class file from...
PersOffers/WebContent/WEB-INF/classes/pers_offers
...onto the JSP file. This class is one of the classes we generated in the content resource wizard.
- In the Properties window, select offersSpot from the Id list.
- Drag the pers_offers.Per_Offers_UserSpot.class file from...
PersOffers/WebContent/WEB-INF/classes/pers_offers
...onto the JSP file.
- In the Id field, type userSpot.
- Switch to source mode in the JSP file editor.
- Replace the existing text with the following sample. The setRequest calls pass the user context to personalization:
<%@ page session="false" contentType="text/html" import="java.util.*, pers_offers.*"%> <%@ taglib uri="/WEB-INF/tld/portlet.tld" prefix="portletAPI" %> <portletAPI:init/> <jsp:useBean class="pers_offers.Pzn_offersSpot" id="offersSpot"></jsp:useBean> <jsp:useBean class="pers_offers.Per_Offers_UserSpot" id="userSpot"></jsp:useBean> <% offersSpot.setRequest(request); userSpot.setRequest(request); %>
- Save the file and check for syntax errors.
- Insert the following code at the end of the JSP file:
<DIV style="margin: 6px"> <H3 style="margin-bottom: 3px">Welcome to Personalized Offers!</H3></DIV> <BR> Here is a personalized offer:<BR> <%=offersSpot.getRuleContent()[0].getTitle() %> <br> <%=offersSpot.getRuleContent()[0].getDetails() %>
- Save and close the JSP file.
What to do next
You finished the basic coding of the personalized portlet. We can now export the WAR file from Rational Application Developer and install the portlet in WebSphere Portal.
Parent topic: Develop a personalized portletPrevious topic: Create the Personalization user resource classes and content spot
Next topic: Export the WAR file and install the portlet