Friday, 31 October 2014

Exploring trust association interceptor (TAI) in websphere portal8

                                                    Websphere has thought about external authentication and provided a authentication proxy or a authentication plugin. Such plugin is TAI using this we can authenticate a user and send that userid to websphere container as authenticated user. 

External authentication --> TAI interceptor --> success --> Create LTPA token and store it in browser --> websphere container


TAI interceptor :- Using TAI interceptor we can first decide whether to parse request or not. If request is being parsed we can decide whether to send it to was or not. 

Usecase :- Integrating tomcat authentication with websphere portal

Step1  :- Create a class which extends TrustAssociationInterceptor , Add websphere portal server to classpath to avoid errors{Methods and significance is explained below}

import java.util.Properties;   import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse;   import com.ibm.websphere.security.WebTrustAssociationException; import com.ibm.websphere.security.WebTrustAssociationFailedException; import com.ibm.wsspi.security.tai.TAIResult; import com.ibm.wsspi.security.tai.TrustAssociationInterceptor;   /** * A simple custom Trust Association Interceptor. */ public class TomcatInterceptor implements TrustAssociationInterceptor {   /* * In this method we can validate whether the request is from trusted * client or not. * */ public boolean isTargetInterceptor(HttpServletRequest req) throws WebTrustAssociationException { // Lets do some validation on the incoming request String username = req.getParameter("username");   // If we got a username the request for TAI only. if (username != null) return true;   return false; }   /* 
* Using this method we can decide to pass request to WAS server ot not */ public TAIResult negotiateValidateandEstablishTrust(HttpServletRequest req, HttpServletResponse resp) throws WebTrustAssociationFailedException { // Validate and establish trust with WebSphere Application Server. TAIResult result = null;   String username = req.getParameter("username");   // Create the TAIResult with username we got. result = TAIResult.create(HttpServletResponse.SC_OK, username);   // return the TAIResult. return result;   }   /* 
* We can put some initialization codes here */ public int initialize(Properties arg0) throws WebTrustAssociationFailedException { // The TAI initialization code goes here. return 0; }   /* * You can return the version of TAI */ public String getVersion() { // The version of TAI we are using. return "1.0"; }   /* * Type of TAI */ public String getType() { // The type of TAI. return "Custom TAI 1.0"; }   /* * All cleanup code goes here */ public void cleanup() { // The TAI clean up code goes here. } }

Step 2 :- Now you need to export this jar and put it under (C:\IBM\WebSphere\AppServer\lib\ext)

Now we need to enable trust association in portal so login to application server and navigate till this page and click on trust association



Make sure Enable trust association is checked. Then click on Interceptors


Click on new and add your interceptor


Please enter your interceptor name in Interceptor class name field




Click save and then restart the server



Step 3 :- Now download tomcat server and then add it to your rad. Then create a J2EE application with login page and point it to below servlet.

Login page :-

<!DOCTYPE HTML><%@page language="java"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>LoginPage</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<h1> Login to tomcat application </h1>

<form action="<%=request.getContextPath()%>/LoginServlet" method="post">

Username :- <input type="text" name="username" />
Password :- <input type="password" name="password">
<input type="submit" value="submit">

</form>

</body>
</html>


Servlet :-
package com.authentication.login; import java.io.IOException; import javax.servlet.RequestDispatcher; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; /** * Servlet implementation class LoginServlet */ @WebServlet("/LoginServlet") public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L; /** * @see HttpServlet#HttpServlet() */ public LoginServlet() { super(); // TODO Auto-generated constructor stub } /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub String username = request.getParameter("username"); request.setAttribute("username", username); RequestDispatcher rd = request.getRequestDispatcher("/JSPS/SuccessPage.jsp"); rd.include(request, response); } }


Success Page :-


<!DOCTYPE HTML><%@page language="java"
contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<html>
<head>
<title>SuccessPage</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
</head>
<body>
<!-- Pass username for authentication !-->
<a href="https://wportal8.atech.com:10029/wps/myportal?username=${username}">Navigate to portal</a>

</body>

</html>

Step4 :- Now launch the J2ee application then login and click on the link to navigate to portal then user will be navigated to portal without asking for userid and password.










Exploring Dyanamic user interfaces in websphere portal8.0

Dynamic user interfaces :- Dynamic ui's are pages or portlets that are created from the definition of existing page or portlet. Dynamic uis can be created only from DynamicUiManager Api. The scope of this dynamic ui is to that session only these data is not persisted in database. This Dynamic ui can be destroyed before the session ends also.

Developing a dynamic UI configuration :-  Let us have a use-case of manager he has to approve leave. Process for approving the leave needs some clicks in the browser. If 10 people are applying for leave. Manager should go through everyone in webpage and then approve it. To make managers work as easy as possible we can get 10 virtual pages with each member request in corresponding page.

Step1 :-  Creating the extension node for dynamic pages.
    1. Create the page to be used for containing dynamic UIs.
    2. Assign a unique name{DynamicUiInterface} to the node. To do this, use the Unique names portlet or do it in edit page.
    3. Change to the directory was_profile_root/ConfigEngine.
    4. Run the following config task: 
      • Windows: ConfigEngine.bat action-enable-page-as-extension-node-wp.dynamicui.config -DPageUniqueName=DynamicUiInterface -DPortalAdminPwd=passw0rd_123

Step 2 :- Now you have to create a portlet and then add to DynamicUiInterface portlet page and then set below portlet preferences in it.

<portlet-preferences>
<preference>
<name>com.ibm.portal.context.enable</name>
<value>true</value>
</preference>
</portlet-preferences>

Step 3 :- Final portlet code should like below

package com.ibm.dynamicuiportlet;

import java.io.*;
import java.util.*;

import javax.naming.CompositeName;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.Name;
import javax.naming.NamingException;
import javax.portlet.*;

import com.ibm.portal.ObjectID;
import com.ibm.portal.dynamicui.DynamicUICtrl;
import com.ibm.portal.dynamicui.DynamicUIManagementException;
import com.ibm.portal.portlet.service.PortletServiceHome;
import com.ibm.portal.portlet.service.dynamicui.DynamicUIManagementFactoryService;
import com.ibm.portal.portlet.service.state.RedirectURLGeneratorFactoryService;
import com.ibm.portal.propertybroker.property.Direction;
import com.ibm.portal.propertybroker.property.PropertyController;
import com.ibm.portal.propertybroker.property.PropertyValue;
import com.ibm.portal.propertybroker.service.PropertyFactory;
import com.ibm.portal.state.EngineURL;
import com.ibm.portal.state.RedirectURLGenerator;
import com.ibm.portal.state.exceptions.StateException;
import java.util.logging.Logger;
import com.ibm.wps.engine.localized.LocalizedContextImpl;

/**
 * A sample portlet based on GenericPortlet
 */
public class DynamicUiPortlet extends GenericPortlet {

public static final String JSP_FOLDER    = "/_DynamicUiPortlet/jsp/";    // JSP folder name

public static final String VIEW_JSP      = "DynamicUiPortletView";         // JSP file name to be rendered on the view mode

public static final Logger logger = Logger.getLogger(DynamicUiPortlet.class.getName());

DynamicUIManagementFactoryService dynamicUIManagerFactoryService = null;
RedirectURLGeneratorFactoryService redirectService = null;
PropertyFactory propertyFactory = null;


/**
* @see javax.portlet.Portlet#init()
*/
public void init() throws PortletException{
super.init();
Context ctx;
try{
ctx = new InitialContext();
// Obtain a reference to the Dynamic UI Management Factory service
PortletServiceHome dynamicUIManagerFactoryServiceHome = (PortletServiceHome) 
ctx.lookup("portletservice/com.ibm.portal.portlet.service.dynamicui.DynamicUIManagementFactoryService"); 
dynamicUIManagerFactoryService = (DynamicUIManagementFactoryService) 
dynamicUIManagerFactoryServiceHome.getPortletService(DynamicUIManagementFactoryService.class);

// Obtain a reference to the property factory
PortletServiceHome serviceHome = (PortletServiceHome) 
ctx.lookup("portletservice/com.ibm.portal.propertybroker.service.PropertyFactory"); 
propertyFactory
(PropertyFactory)serviceHome.getPortletService(com.ibm.portal.propertybroker.service.PropertyFactory.class);

// If the dynamic UI should be displayed immediately upon launch,
// obtain a reference to the RedirectURLGeneratorFactory service 
PortletServiceHome redirectServiceHome = (PortletServiceHome) 
ctx.lookup("portletservice/com.ibm.portal.portlet.service.state.RedirectURLGeneratorFactoryService");
redirectService = (RedirectURLGeneratorFactoryService) 
redirectServiceHome.getPortletService(RedirectURLGeneratorFactoryService.class);
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

/**
* Serve up the <code>view</code> mode.
* @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
*/
public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
// Set the MIME type for the render response
response.setContentType(request.getResponseContentType());

// Invoke the JSP to render
PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(getJspFilePath(request, VIEW_JSP));
rd.include(request,response);
}

/**
* Process an action request.
* @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
*/
public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
String specialAction = request.getParameter("com.ibm.portal.action");
PortletSession portletSession = request.getPortletSession();

if (specialAction != null &&
specialAction.equals("com.ibm.portal.context.receive")) 
{
//this indicates context was passed to the launched page
Map contextMap = (Map)
request.getAttribute("com.ibm.portal.context");

logger.info("Map object :-"+ contextMap.toString());

Object propertyValue =  (Object) contextMap.get("");

portletSession.setAttribute("", propertyValue);

}


try {
//Retrieving portlet object id
Context ctx= new InitialContext();
Name portletName = 
new CompositeName("portal:config/portletdefinition");
portletName.add("com.ibm.dynamicuiportlet.DynamicUiPortlet.a176350594");
portletName.add("DynamicUiPortlet");  
ObjectID portletDefOID = (ObjectID) ctx.lookup(portletName);

//Obtain the dynamic control
DynamicUICtrl DynamicUICtrl = 
dynamicUIManagerFactoryService.getDynamicUICtrl(request, response, "DynamicUiPortlet");

//get the page Id
Name uniqueName = new CompositeName("portal:uniquename");
uniqueName.add("DynamicUiInterface");//Current page uniquename
ObjectID oidForUniqueName = (ObjectID) ctx.lookup(uniqueName);

//launch page or portlet using addPage or addPortlet
ObjectID newObjectId = DynamicUICtrl.addPage(oidForUniqueName, null, null);

//Navigating user to newly created page
RedirectURLGenerator redirector = 
redirectService.getURLGenerator(request, response);
EngineURL redirectURL = redirector.createPortletURL(portletDefOID);
response.sendRedirect(redirectURL.toString());
} catch (NamingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (DynamicUIManagementException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (StateException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

}

/**
* Returns JSP file path.
* @param request Render request
* @param jspFile JSP file name
* @return JSP file path
*/
private static String getJspFilePath(RenderRequest request, String jspFile) {
String markup = request.getProperty("wps.markup");
if( markup == null )
markup = getMarkup(request.getResponseContentType());
return JSP_FOLDER + markup + "/" + jspFile + "." + getJspExtension(markup);
}

/**
* Convert MIME type to markup name.
* @param contentType MIME type
* @return Markup name
*/
private static String getMarkup(String contentType) {
if( "text/vnd.wap.wml".equals(contentType) )
return "wml";
else
return "html";
}

/**
* Returns the file extension for the JSP file
* @param markupName Markup name
* @return JSP extension
*/
private static String getJspExtension(String markupName) {
return "jsp";
}


}

Comment :- This code is not dev ready it just implementation stage. even there are open PMRs

Thursday, 30 October 2014

Changing port in websphere portal 8.0

Complete the following steps to change the port values:

Note: The starting port parameter is required for a successful completion of the modify-ports-by-startport task. Once you specify a start port, this port becomes the base for assigning port values. The code increments this value as each port is assigned, which means that the WebSphere Portal ports are assigned incrementally starting with the port defined with the modify-ports-by-startport task.

  1. Run the following task from the wp_profile_root/ConfigEngine directory to generate the WebSphere_Portal_PortMatrix.txt file:
  2. Note: The port file is located in the wp_profile_root/ConfigEngine/log directory. It lists the WebSphere Portal (WebSphere_Portal) ports for your installation.
    • Windows™: ConfigEngine.bat list-server-ports-by-name -DServerName=WebSphere_Portal -DWasPassword=passw0rd_123
  3. Stop the WebSphere_Portal server.
  4. Run the following command to change the starting port number:
    • Windows: ConfigEngine.bat modify-ports-by-startport -DWasPassword=passw0rd_123 -DModifyPortsServer=WebSphere_Portal -DStartPort=80039
  5. Run the following command to change ports using the port file:
  6. Note: Sample port files are available on the Setup disc. The following information is an example of a port file although the port values will be different based on your environment:
    BOOTSTRAP_ADDRESS=10035
    SOAP_CONNECTOR_ADDRESS=10025
    ORB_LISTENER_ADDRESS=10034 
    SAS_SSL_SERVERAUTH_LISTENER_ADDRESS=10041
    CSIV2_SSL_SERVERAUTH_LISTENER_ADDRESS=10036
    CSIV2_SSL_MUTUALAUTH_LISTENER_ADDRESS=10033
    WC_adminhost=10042
    WC_defaulthost=10039
    DCS_UNICAST_ADDRESS=10030
    WC_adminhost_secure=10032
    WC_defaulthost_secure=10029
    SIP_DEFAULTHOST=10027
    SIP_DEFAULTHOST_SECURE=10026
    IPC_CONNECTOR_ADDRESS=10037
    SIB_ENDPOINT_ADDRESS=10028
    SIB_ENDPOINT_SECURE_ADDRESS=10038
    SIB_MQ_ENDPOINT_ADDRESS=10040
    SIB_MQ_ENDPOINT_SECURE_ADDRESS=10031

    • Windows: ConfigEngine.bat modify-ports-by-portsfile -DWasPassword=passw0rd_123 -DModifyPortsServer=WebSphere_Portal -DPortsFile=full path to ports file
  7. Restart the WebSphere_Portal server.

Wednesday, 29 October 2014

Configuring websphere portal to use LDAP(Microsoft active directory)


Prerequisites :- 
  •      Microsoft active directory should be installed before only
  •      Have server name , port-number,password handy



   


Step1 :- Login to portal/connections login page and navigate till below page and click on (configure )at bottom and click (Add base entry to Realm) and click on add click on (Add repository)



Step 2 :-  Now enter below details in it


Step3 :- Click ok and then click on (Add base entry to Realm)  again and select AD then enter below details


Step 4 :- Now click on Apply and then ok. Restart portal server. Now portal server will use Microsoft directory

Enabling sso between websphere portal and Ibm connections server


    Exploring Co:head and Co:config in websphere portal 8

    Basic artifacts and their relation

    The theme modularization framework foresees the following major artifacts and relations to one another.
    The relations of the major artifacts are depicted in the following figure:
    Major artifact relations model
    A theme is assigned to a portal page. Dynamic content spots are used to write all of the data for modules that have contributions for a certain type. The module framework provides the dynamic content spotsco:config and co:head. The theme must provide one or more profiles, which declares the set of modules that are used for that profile. One of these profiles is used by each page to which the theme is applied. The profile used for the page is the default profile that the theme developer or administrator defines for the theme by setting the theme metadata resourceaggregation.profile.
    The Page administrator can explicitly overwrite the default by setting the page metadata resourceaggregation.profile.
    The modules available in the system can either be registered through the extension point com.ibm.portal.resourceaggregator.module in a plugin.xml file, or using a JSON file located within a theme in the folder <theme-root>/contributions. This path is not customizable.
    For example, the head spot, <link rel=”dynamic-content” href=”co:head”></link>, and aggregates all contributions of type head.
    You choose where to place dynamic content spots as long as the following constraints are fulfilled:
    • The head spot must be located inside the <head> element in the page markup. The <head> element must be placed before the <body> element in the page markup.
    • The config spot must be located inside the <body> element in the page markup. Make the config spot the last element before the closing tag.
    Contributions to the head extension point are best used for data that must be loaded at the beginning of the page. These contributions include producing markup that is only valid inside the <head> element or providing core functions that must be available to other inline code within the page body. For example, <link> elements can show only inside the head element, therefore all CSS must be added to the head contribution. Also, any inline JavaScript that uses a utility function to attach an event handler to the onload event, such as dojo.addOnLoad, depends on that function being defined earlier in the page markup.
    Place the config spot at the end of the page body element. This placement allows the bulk of the JavaScript resources and other enablement code to be written to the markup after the page layout and content area. The perceived responsiveness of the server increases by showing the page content while the browser is still downloading resources that are defined after the content area. However, there is no guarantee that the config spot is placed there, and it is valid for a theme designer to place the config spot inside the <head> element when it fulfills the first constraint.
    Because the location of the config spot can vary, any code that displays inside the page content should not assume that the config spot was already generated. The JavaScript code in the content area that depends on other JavaScript modules loaded by the config spot are deferred until the onload event is triggered which guarantees that the code inside a portlet, for example, always works regardless of the position of the config spot. An example is portlet JavaScript that creates client-side widgets on page load. Widget modules themselves can be loaded by the config spot while the code that creates and uses them is executed onload.
    Modules can declare dependencies on prerequisite modules. Additionally, they can declare their capabilities, which enable portlets and other code on the page to query the availability of a certain capability.

    Monday, 27 October 2014

    Customizing users card in websphere portal8

    Control display duration of user card :- 
    1. Select the appropriate websphere server console, depending on your environment:
    2. Start the WebSphere Integrated Solutions Console by entering the URL in the location field of a Web browser: 
    3. http://localhost:10032/ibm/console
    4. In the navigation, click Resources -> Resource Environment -> Resource Environment Providers.
    5. Locate and click the resource WP PeopleService.
    6. Under Additional Properties, click Custom Properties.
    7. Locate personTagTimeout and then set its value in milliseconds.
    8. Click Apply and then save the settings.
    9. Restart the portal server.

    Customizing the look of person card :-
    1. Locate your theme's Cascading Style Sheet (CSS) files. The location can differ between themes, but the CSS files are often in a /css or /styles folder within your theme. For more information on locating your theme's files, see Location of theme resources.
    2. Locate and open the CSS file that contains the Person Card styles. The file may differ by theme, but is often either styles_people.jpsfstyles_ibm.jspf, or portalLegacy.css
    3. You can locate the specific file by searching file contents of the CSS folder for one of the CSS style definitions listed in the following table (for example, personMenu), or by loading the portal theme in a Web browser and using Web development tools to inspect the CSS style definitions loaded in the page.
    4. Find the following style definitions in the file and modify them as needed:
    5. Modify this style definitionTo do this
      .menu_drop_iconChange the look and feel of the Click for Person Card option.
      .hyperlinkChange the appearance of the person name hyperlink.
      .photoCard imgChange the style of the image that displays in the business card section of the Person card.
      .businessCard .cardnameChange the style of the name that displays in the business card section.
      .businessCard liChange the style of other user details that display in the business card section.
      .personMenuActionsChange the style of the actions such as Profile and Send Mail that display on the Person card.
      .personMenuChange the style of the container that holds the business card and action items as a single unit.

    6. Touch the timestamp on the theme's styles.jsp so that it will be recompiled by the JSP compiler.
    7. You can touch the timestamp by editing the file, adding a blank line, and saving the file.
    8. Clear the browser's cache and cookies.
    9. Call the Person card and verify your changes. 

    Exploring collaborative services(person tag,live text microformat) api websphere portal8

    Collaborative services :- Collaborative services are methods and java server pages tlds provided by portal to integrate lotus collaborative options. Portal provides a tld file under this location{C:\IBM\WebSphere\PortalServer\people\people.impl\persontag\taglib\shared\app\WEB-INF\tld}. Generally it contains jar file you need to unzip and look for WEB-INF folder.

    PersonTag :-  Using person tag we can get links in your custom portlet. These links can be used as person tags on hover over these tags we can show person image or some status details. Default provided options are click to view business card, actions to provide custom email action. If there is no business card it just shows the person name. If lotus notes is integrated it provides option to add as a sametime contact.

    Integrating business card and online status in custom portlet :- 

    Step1 :- Create portal project and then create a portlet in it. then modify the view jsp as given below.

    <%@page session="false" contentType="text/html" pageEncoding="ISO-8859-1" import="java.util.*,javax.portlet.*,com.ibm.bussinesscardportlet.*" %>
    <%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>        
    <%@taglib uri="http://www.ibm.com/xmlns/prod/websphere/portal/v6.1/portlet-client-model" prefix="portlet-client-model" %>  
    <%@taglib uri="/WEB-INF/tld/people.tld"prefix="pa"%>      
    <portlet:defineObjects/>
    <portlet-client-model:init>
          <portlet-client-model:require module="ibm.portal.xml.*"/>
          <portlet-client-model:require module="ibm.portal.portlet.*"/>   
    </portlet-client-model:init> 


    <DIV style="margin: 6px">

    <h1>Using person tag</h1>
    <pa:person value="uid=wpsadmin,O=defaultWIMFileBasedRealm" valueType="LDAPDN" displayName="wpsadmin" isActive="true" />
    <br/>

    <h1>Using live text</h1>
    <span class='vcard'>
    <a class='fn' href='javascript:SemTagMenu.a11y(event)' style='color:black; text-decoration:none;' 
       onclick='return false;'>${displayName}</a>
       <span class='userObjectId' style='display:none;'>${objectId}</span>
    </span>

    </DIV>

    Step 2 :- In portlet doView write code to fill above dynamic data in view jsp

    package com.ibm.bussinesscardportlet;

    import java.io.*;
    import java.util.*;

    import javax.naming.Context;
    import javax.naming.InitialContext;
    import javax.naming.NamingException;
    import javax.portlet.*;

    import com.ibm.portal.ObjectID;
    import com.ibm.portal.identification.Identification;
    import com.ibm.portal.portlet.service.PortletServiceHome;
    import com.ibm.portal.serialize.SerializationException;
    import com.ibm.portal.um.PumaProfile;
    import com.ibm.portal.um.User;
    import com.ibm.portal.um.exceptions.PumaException;
    import com.ibm.portal.um.portletservice.PumaHome;

    /**
     * A sample portlet based on GenericPortlet
     */
    public class BussinessCardPortlet extends GenericPortlet {

    public static final String JSP_FOLDER    = "/_BussinessCardPortlet/jsp/";    // JSP folder name

    public static final String VIEW_JSP      = "BussinessCardPortletView";         // JSP file name to be rendered on the view mode

    public String PUMA_JNDI_NAME = "portletservice/com.ibm.portal.um.portletservice.PumaHome";

    public static PortletServiceHome psh = null;
    public Identification identification = null;


    /**
    * @see javax.portlet.Portlet#init()
    */
    public void init() throws PortletException{
    super.init();
     Context ctx;
     try {
      ctx = new InitialContext();
      //Retrieve the service object
      psh = (PortletServiceHome)ctx.lookup(PUMA_JNDI_NAME);
      identification = (Identification)ctx.lookup(Identification.JNDI_NAME);
     } catch (NamingException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
     }
    }

    /**
    * Serve up the <code>view</code> mode.
    *
    * @see javax.portlet.GenericPortlet#doView(javax.portlet.RenderRequest, javax.portlet.RenderResponse)
    */
    public void doView(RenderRequest request, RenderResponse response) throws PortletException, IOException {
    // Set the MIME type for the render response
    response.setContentType(request.getResponseContentType());
    //displayName
    String user = request.getRemoteUser();
    request.setAttribute("displayName", user);

    PumaHome pumHome =  psh.getPortletService(PumaHome.class);
    PumaProfile pumaProfile = pumHome.getProfile(request);
    try {
    User currentUser = pumaProfile.getCurrentUser();
    ObjectID objectId = currentUser.getObjectID();
    request.setAttribute("objectId",identification.serialize(objectId));
    } catch (PumaException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    } catch (SerializationException e) {
    // TODO Auto-generated catch block
    e.printStackTrace();
    }
    // Invoke the JSP to render
    PortletRequestDispatcher rd = getPortletContext().getRequestDispatcher(getJspFilePath(request, VIEW_JSP));
    rd.include(request,response);
    }

    /**
    * Process an action request.
    *
    * @see javax.portlet.Portlet#processAction(javax.portlet.ActionRequest, javax.portlet.ActionResponse)
    */
    public void processAction(ActionRequest request, ActionResponse response) throws PortletException, java.io.IOException {
    }

    /**
    * Returns JSP file path.
    *
    * @param request Render request
    * @param jspFile JSP file name
    * @return JSP file path
    */
    private static String getJspFilePath(RenderRequest request, String jspFile) {
    String markup = request.getProperty("wps.markup");
    if( markup == null )
    markup = getMarkup(request.getResponseContentType());
    return JSP_FOLDER + markup + "/" + jspFile + "." + getJspExtension(markup);
    }

    /**
    * Convert MIME type to markup name.
    *
    * @param contentType MIME type
    * @return Markup name
    */
    private static String getMarkup(String contentType) {
    if( "text/vnd.wap.wml".equals(contentType) )
    return "wml";
            else
                return "html";
    }

    /**
    * Returns the file extension for the JSP file
    *
    * @param markupName Markup name
    * @return JSP extension
    */
    private static String getJspExtension(String markupName) {
    return "jsp";
    }

    }

    Step 3 :-  Output


    hover on any one of it to see the menu


    Hover on the other one also


    Now click on it to see user business card


    Now click on profile to see full profile of user


    Now hover on second approach and click on menu link


    Now click on profile to view full profile of user









    Custom single threaded java server

     package com.diffengine.csv; import java.io.*; import java.net.*; import java.util.Date; public class Server { public static void main(Str...