Creating a JSR-168 Portlet

This section describes how to create a simple JSR-168 portlet in Eclipse and register it with the AquaLogic Interaction portal. The portlet you create will implement the "view" mode and display the message "Hello, World."

To create the JSR-168 portlet:

  1. Create a JSP page for the "view" mode of the portlet:

    1. In Project Explorer, right-click on your project and select New | JSP.

    2. For the parent folder, select <project name>/WebContent.

    3. Enter a File name. For example, HelloWorldView.jsp.

    4. Replace the generated code with the following:

      <%@ page language="java" %>
      <h4>Hello, World.</h4>

    5. Save the file.

  2. Create a Java class that extends javax.portlet.GenericPortlet:

    1. In Project Explorer, right-click on your project and select New | Class.

    2. Enter a Package. For example, samples.

    3. Enter a Name. For example, HelloWorldPortlet.

    4. For Superclass enter javax.portlet.GenericPortlet.

    5. Click Finish.

  3. Code the doView method to render the JSP file you created. For example:

package samples;

import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.PortletRequestDispatcher;
import javax.portlet.PortletSecurityException;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.portlet.UnavailableException;
import javax.portlet.PortletPreferences;
import javax.portlet.ActionResponse;
import javax.portlet.ActionRequest;

public class HelloWorldPortlet extends GenericPortlet {

private static final String CONTENT_TYPE_HTML = "text/html;charset=UTF-8";

protected final void doView(RenderRequest request, RenderResponse response)
throws UnavailableException,




String path = "/HelloWorldView.jsp";
PortletRequestDispatcher rd = this.getPortletContext().getRequestDispatcher(path);

rd.include(request, response);

catch (Exception e)

throw new PortletException(e);




  1. Register the HelloWorld portlet in WEB-INF/portlet.xml:

    1. If you do not have an existing portlet.xml, create portlet.xml in the project's WEB-INF directory.

    2. Register the HelloWorld portlet and have it support the "view" mode. For example:

<?xml version="1.0" encoding="UTF-8"?>


<portlet-app xmlns=""



<description>Hello World</description>
<display-name>Hello World</display-name>


<title>HelloWorld Portlet</title>



  1. Log in to AquaLogic Interaction and go to Administration.

  2. Create a Remote Server object for your server:

    1. From the Create Object... drop-down menu, choose Remote Server.

    2. Enter the Base URL for your server. For example, http://localhost:8080/.

    3. Name and save the remote server.

  3. Create a Web Service object for your JSR-168 portlet:

    1. From the Create Object... drop-down menu, choose Web Service - Remote Portlet.

    2. Select the Remote Server you created.

    3. For Portlet URL enter <project name>/portlet/<portlet name>/mode/view. For example,  jsr168Web/portlet/HelloWorldPortlet/mode/view

    4. Name and save the web service.

  4. Create a Portlet object for your JSR-168 portlet:

    1. From the Create Object... drop-down menu, choose Portlet.

    2. Choose the web service you created.

    3. Name and save the portlet.

  5. Place the portlet on a portal page. The portlet may timeout and need to be refreshed before it displays the Hello, World message.

Next: Adding an Edit Page