Client profile information (CC/PP) in portlets

For each incoming request, the portal tries to determine the client that issued the request. It is important to determine the client in order to know its capabilities and respond properly. The portal database contains a repository of client profiles, providing all relevant information about the supported clients. The Portal uses JSR 188, which provides a standard API named "CC/PP" for accessing client profiles. The Java Portlet Specification allows portlets to access the client profile through a request attribute. The Getting Started With Composite Capabilities/Preference Profiles and JSR 188 has more information about CC/PP

I wanted to learn how the CC/PP works so i built this sample portlet, which queries list of all the profile attributes and then prints the attributes and there values in table format like this. You can download the sample code from here

This is source code of the portlet

package com.webspherenotes.misc;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;

import javax.ccpp.Attribute;
import javax.ccpp.Component;
import javax.ccpp.Profile;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;

public class CPIPortlet extends GenericPortlet{
protected void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
System.out.println("Entering CPIPortlet.doView()");
Profile clientProfile =
(Profile) request.getAttribute(PortletRequest.CCPP_PROFILE);
System.out.println("Profile Object " + clientProfile);
HashMap attributeMap = new HashMap();
if(clientProfile != null){
processProfile(clientProfile );
Iterator attributeIt = clientProfile.getAttributes().iterator();
Attribute attribute =;
if(attribute != null){

System.out.println(attribute.getName() + " = " + attribute.getValue());
attributeMap.put(attribute.getName(), attribute.getValue());
System.out.println("Attribute Map " + attributeMap);
request.setAttribute("clientProfileAttributeMap", attributeMap);
getPortletContext().getRequestDispatcher("/index.jsp").include(request, response);
System.out.println("Entering CPIPortlet.doView()");
public void processProfile(Profile profile) {
System.out.println("Entering processProfile");
Set comps = profile.getComponents();
for(Iterator i = comps.iterator(); i.hasNext(); ) {
Component comp = (Component);
System.out.println("Component: " + comp.getName());
Set attrs = comp.getAttributes();
for(Iterator j = attrs.iterator(); j.hasNext(); ) {
Attribute attr = (Attribute);
Object value = attr.getValue();
System.out.println("\tAttribute: " + attr.getName() +
" = " + attr.getValue());
System.out.println("Entering processProfile");

In the doView() method of the CPIPorltet i am reading the PortletRequest.CCPP_PROFILE attribute from the PortletRequest and then i am using the Profile attribute to first find out list of the attributes and then generating table of this data using JSP


Vikas Chaudhary said...

Battery Mantra is Authorized exide car battery dealer in Noida and Greater Noida. We are providing our service in Indirapuram, Delhi, Ashok Nagar.

Exide Battery Dealer in Noida
Battery Dealer in Noida
Authorized Battery Dealer in Noida
Car Battery Dealer in Noida
Car Battery Dealer
Exide Battery Dealer

srjwebsolutions said...

We are leading responsive website designing and development company in Noida.
We are offering mobile friendly responsive website designing, website development, e-commerce website, seo service and sem services in Noida.

Responsive Website Designing Company in Noida
Website Designing Company in Noida
SEO Services in Noida
SMO Services in Noida

EG MEDI said... is online medical store pharmacy in laxmi nagar Delhi. You can Order prescription/OTC medicines online.
Cash on Delivery available. Free Home Delivery

Online Pharmacy in Delhi
Buy Online medicine in Delhi
Online Pharmacy in laxmi nagar
Buy Online medicine in laxmi nagar
Onine Medical Store in Delhi
Online Medical store in laxmi nagar
Online medicine store in delhi
online medicine store in laxmi nagar
Purchase Medicine Online
Online Pharmacy India
Online Medical Store