Oracle Portal Development Kit
How to Build a Multi-Programming Language Portlet Using the PDK

PDK Release 2 (9.0.2 and later)

Once you have successfully installed and deployed the PDK, you may want to begin building URL-based portlets of your own. The PDK enables you to create URL-based portlets that use multiple programming languages to implement the various portlet modes.

This article describes how to build a basic multi-programming language URL-based portlet.

### ASSUMPTIONS

1. You have already installed the samples downloaded with the most recent PDK and and understand the steps required to display a URL-based portlet on a portal page. For more information on installing the sample, please review the Installing the PDK Framework and Samples article.

2. You have already installed Internet Information Server (IIS) and are able to display ASP pages using IIS.

3. You are able to access your ASP's, JSP's and HTML through a URL.

### CREATING A SHOW MODE IN ASP

This section describes how to create a show mode for your portlet using Active Server Pages.

1. Write a simple ASP that displays a welcome greeting along with the time. You may write your own or use the sample provided.

   > <%@ Language=VBScript %> <html> <head> <title>SAMPLE ASP</title> </head> <body> <center><B><U><font size="5" font color= black> <%FirstVar = "Welcome to the PDK Integration ASP Portlet!"%> <%=FirstVar%></U></B></FONT> </center><br> <CENTER><blink><b><%IF Hour(time)>18 OR Hour(time)<4 THEN%> Good Night Everyone. <%ELSE%> Good Morning Everyone. <%END IF%></blink></b></CENTER> <% FirstVar = "Hello world!" %><br> <CENTER><b>The time is: <%=time%></b></CENTER><BR><BR> </body> </html>

2. Place this in a file and save it as aspportlet.asp.

3. Move the File to your ASP directory for Internet Information Server. Make sure it is possible to display the ASP in the browser. For example: http://host.domain:port/aspdirectory/aspportlet.asp

### CREATING A HELP MODE IN JSP

This section describes how to create a show mode for your portlet using Java Server Pages.

1. Write a simple JSP that displays simple help information. You may write your own or use the sample provided.

   > <%@ page language = "java" info="a hello world example" import = "oracle.portal.provider.v1.http.*" session = "false" %> <html> <center> <b>This is the help show mode created in JSP to interact with an ASP portlet.</b><br><br> <hr width = 100%> To view the portlet in full screen mode click on the portlet title in the left corner of the title banner. <hr width = 100%> </center> </html>

2. Place this in a file and save it as help.jsp.

3. Move the File to your JSP directory. Make sure it is possible to display the JSP in the browser. For example: http://host.domain:port/jspdirectory/help.jsp

### CREATING AN ABOUT MODE IN HTML

This section describes how to create a show mode for your portlet using HTML.

1. Write a simple HTML page that displays simple information about the portlet. You may write your own or use the sample provided.

   > </html> <html> <center> <hr width=75%> <table width="50%"> <tr><td align="center"> <b>Hello Multi Show Mode ASP Portlet - Displays a portlet created using ASP, that has show modes created using ASP, JSP and HTML. </b></td></tr> </table> </center> </html>

2. Place this in a file and save it as about.html

3. Move the File to your HTML directory. Make sure it is possible to display the JSP in the browser. For example: http://host.domain:port/htmldirectory/about.html

### CREATING A SHOW DETAILS MODE IN ASP

This section describes how to create a Show Details mode for your portlet using ASP.

1. The ASP that was created for the actual Portlet can be used for the Show Details mode.

### UPDATING FRAMEWORK

This section explains how to create a provider.xml to describe and list your new portlet. It then explains how to update the Oracle HTTP Server to view the new provider.xml.

### Creating a provider.xml

1. In this section you will create a new provider.xml. Creating a new provider.xml will allow you add new portlets without affecting Web Providers already registered with Oracle 9iAS Portal.

   You must supply a URL's for the portlets that you created. The URL is added in the showPage, helpPage and aboutPage between the <pageurl> tags. doing this will Provide the actual Portlet.

   There are two steps when adding different show modes to a portlet. First, you must activate the Show Mode by the setting a value of true to the <hasHelp>, <hasAbout> and<showDetails>tags. For example: <hasHelp>true</hasHelp>. Second, within the show mode rendering section, you must specify the correct URL for the show mode in question between the <pageURL> tags. For example <helpPage>.

> > - Add the following entry to the file. Note: If you plan to add additional portlets in the future, verify that your portlet ID is unique for this provider.

> > - All the changes that need to be carried out are highlighted in bold. (replace with your own proxy/host/sample directory setting details.

> > > Note: Make sure to update the page URL and Show Mode URL with your own correct information. The information supplied in the URL's is for example only. The changes are displayed in bold.

> > <?xml version="1.0" encoding="UTF-8"?> <?providerDefinition version="3.1"?> <provider class="oracle.portal.provider.v2.http.URLProviderDefinition"> <providerInstanceClass>oracle.portal.provider.v2.http.URLProviderInstance</providerInstanceClass> <session>true</session> <proxyInfo class="oracle.portal.provider.v2.ProxyInformation"> <httpProxyHost>www-proxy.us.oracle.com</httpProxyHost> <httpProxyPort>80</httpProxyPort> </proxyInfo> <httpsProxyInfo class="oracle.portal.provider.v2.ProxyInformation"> <httpsProxyHost>www-proxy.us.oracle.com</httpsProxyHost> <httpsProxyPort>80</httpsProxyPort> </httpsProxyInfo> <portlet class="oracle.portal.provider.v2.http.URLPortletDefinition"> <id>1</id> <name>multiLingualPortlet</name> <title>Multi Language Portlet</title> <description>This is a sample multi language portlet to test Integration services </description> <timeout>100</timeout> <timeoutMessage>Portlet Timed Out</timeoutMessage> <showEdit>false</showEdit> <showEditDefault>false</showEditDefault> <showPreview>false</showPreview> <showDetails>true</showDetails> <hasHelp>true</hasHelp> <hasAbout>true</hasAbout> <acceptContentType>text/html</acceptContentType> <registrationPortlet>false</registrationPortlet> <renderer class="oracle.portal.provider.v2.render.RenderManager"> <showPage class="oracle.portal.provider.v2.render.http.URLRenderer"> <contentType>text/html</contentType> <accessControl>public</accessControl> <pageUrl>http://host.domain:port/aspdirectory/aspportlet.asp/default.asp</pageUrl> <filterType>text/html</filterType> <filter class="oracle.portal.provider.v2.render.HtmlFilter"> <headerTrimTag>&lt;BODY</headerTrimTag> <footerTrimTag>/BODY></footerTrimTag> <convertTarget>true</convertTarget> </filter> </showPage> <helpPage class="oracle.portal.provider.v2.render.http.URLRenderer"> <contentType>text/html</contentType> <accessControl>public</accessControl> <pageUrl>http://host.domain:port/jspdirectory/help.jsp</pageUrl> <filterType>text/html</filterType> <filter class="oracle.portal.provider.v2.render.HtmlFilter"> <headerTrimTag>&lt;BODY</headerTrimTag> <footerTrimTag>/BODY></footerTrimTag> <convertTarget>true</convertTarget> </filter> </helpPage> <aboutPage class="oracle.portal.provider.v2.render.http.URLRenderer"> <contentType>text/html</contentType> <accessControl>public</accessControl> <pageUrl>http://host.domain:port/htmldirectory/about.html</pageUrl> <filterType>text/html</filterType> <filter class="oracle.portal.provider.v2.render.HtmlFilter"> <headerTrimTag>&lt;BODY</headerTrimTag> <footerTrimTag>/BODY></footerTrimTag> <convertTarget>true</convertTarget> </filter> </aboutPage> <showDetailsPage class="oracle.portal.provider.v2.render.http.URLRenderer"> <contentType>text/html</contentType> <accessControl>public</accessControl> <pageUrl>http://host.domain:port/aspdirectory/aspportlet.asp/default.asp</pageUrl> <filterType>text/html</filterType> <filter class="oracle.portal.provider.v2.render.HtmlFilter"> <headerTrimTag>&lt;BODY</headerTrimTag> <footerTrimTag>/BODY></footerTrimTag> <convertTarget>true</convertTarget> </filter> </showDetailsPage> </renderer> <securityManager class="oracle.portal.provider.v2.security.URLSecurityManager"> <authorizType>public</authorizType> </securityManager> </portlet> </provider>

> 4. Save and close the file. Make sure to name the file "provider.xml".

2. Place the file in any directory other than the location where the jpdk provider.xml resides. Remember the location. For example: C:\myfirstportlet\provider.xml

> Note: Once this new provider.xml has been created, it will replace all the previous versions of the provider.xml. This will cause all the other portlets created using an older version of the provider.xml to stop working. An XLS stylesheet will be provided in a future release to modify the older portlets..

### DEPLOYING YOUR PROVIDER ON OC4J

To configure and deploy your provider on OC4J, please see the section called "Deploying Your Provider on OC4J" in the article, How to Build a URL-Based Portlet.

At this point, you are ready to register your provider and then add the multi-programming language portlet to a page. Please follow the appropriate steps for doing this as described in the Installing the URL-Based Portlet Samples article.

Now that you have successfully created a multi-programming language portlet, please look for other portlet development articles that describe how to add extra features to your portlet, including single sign-on to external URL-based applications, HTML and XML filtering and more.

Here are some reference articles to help you better understand the architecture and technical details of URL-based portlets:

> - A Primer on URL-Based Portlets
> - Understanding the PDK Runtime for URL-Based Portlets
> - Understanding the provider.xml for URL-Based Portlets

Revision History:

- March 2002