Oracle9iAS Portal Developer Kit
How to Build a PERL Portlet using PDK-URL Services

Once you have successfully installed and deployed the URL Services samples, you may want to begin building URL Services samples of your own. When creating your own PERL sample, it will access the same provider framework already used by the URL Services samples. This feature limits the amount of code required by you to create your portlet. What this means is that you only write code when you need to implement changes to the default behavior. For example, to change the portlet body (show mode), simply create a new portlet or alter an existing portlet using the existing framework installed with the PDK-Java (JPDK).

This article describes how to build a basic URL Services portlet in a PERL implementation. The article explains how to write a PERL portlet.

### ASSUMPTIONS

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

2. You are able to access your own PERL samples through a URL.

### CREATING A PORTLET

This section describes how to create a portlet using PERL.

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

   > #C:/ORACLE/ISUITES/perl/5.00503/bin/MSWin32-x86/perl.exe ## ## printenv -- demo CGI program which just prints its environment ## print "Content-type: text/html\n\n"; print "<center><b><i><u><font size='7'>"; print "Hello World!\n"; print "</b></i></u></font></center><br><hr width=75%>"; print "<center><b><i><font size='6'><br>"; $a = "Welcome to the Perl portlet!\n"; print substr ($a, 0, 7); # "Welcome" print substr ($a, 7); # " to Perl!\n" print "<br><br>"; $mytime = localtime(); print $mytime; print "</b></i></font></center><br><hr width=75%>"; use CGI ':standard';

2. Place this in a file and save it as myfirstperlportlet.pl.

3. Move the File to your PERL directory and make sure it is possible to display the PERL sample in the browser. For example: http://host.domain:port/perldirectory/myfirstperlportlet.pl

### 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 to add new portlets without affecting Web Providers already registered with Oracle9iAS Portal.

   1. Open a text editor.

   2. 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.

   Note: Make sure to update the page URL (proxy settings) with your own correct information. The information supplied in the page URL is for example only. The page URL is displayed in bold.

> > <?xml version = '1.0' encoding = 'UTF-8'?> <?providerDefinition version="2.0"?> <provider class="oracle.portal.provider.v1.http.DefaultURLProvider"> <session>true</session> <proxyInfo class="oracle.portal.provider.v1.http.CommonNodeHandler"> <httpProxyHost>www-proxy.us.oracle.com</httpProxyHost> <httpProxyPort>80</httpProxyPort> </proxyInfo> <httpsProxyInfo class="oracle.portal.provider.v1.http.CommonNodeHandler"> <httpsProxyHost>www-proxy.us.oracle.com</httpsProxyHost> <httpsProxyPort>80</httpsProxyPort> </httpsProxyInfo> <portlet class="oracle.portal.provider.v1.http.PortletNodeHandler"> <id>1</id> <name>HelloPERL</name> <title>Hello PERLPortlet</title> <description>This is a sample PERL portlet using URL Services. </description> <timeout>10</timeout> <timeoutMessage>PERL Portlet timed out</timeoutMessage> <acceptContentType>text/html</acceptContentType> <registrationPortlet>false</registrationPortlet> <accessControl>public</accessControl> <renderer class="oracle.portal.provider.v1.RenderManager"> <showPage class="oracle.portal.provider.v1.http.URLPageRenderer"> <contentType>text/html</contentType> <pageUrl>http://hkwong-lap3.us.oracle.com/perl/tperlportlet.pl</pageUrl> <filterType>text/html</filterType> <filter class= "oracle.portal.provider.v1.http.HtmlFilter"> <headerTrimTag>/HEAD</headerTrimTag> <footerTrimTag>/BODY</footerTrimTag> </filter> </showPage> </renderer> <securityManager class="oracle.portal.provider.v1.http.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:\myfirstportletperl\provider.xml

### Updating the zone.properties

1. Currently the zone.properties has an argument called provider_root that points the Adapter to the directory where the provider.xml for the JPDK resides. We will add a new entry to point to our new provider.xml in addition to the previous one.

2. Stop the Oracle HTTP Server.

3. Open zone.properties.

4. Under the Servlet Aliases section add the following:

       servlet.myfirstperl.code=oracle.portal.provider.v1.http.HttpProvider

5. Under the Aliased Servlet Init Parameters section, add the following:

       servlet.myfirstperl.initArgs=provider_root=C:\myfirstportletperl,sessiontimeout=1800000

6. Save and close the file.

7. Start the Oracle HTTP Server.

8. Now, test that you can execute the Adapter by calling the newly added alias. For example, type in the URL:

       http://host.domain:port/servlet/myfirstperl

9. You should receive a sample page.

### VIEWING PORTLET

1. Now that you have successfully tested your new alias. You will need to register a new provider that calls this alias.

2. Register your new Provider.

   1. Name: MyFirstPERLProvider

   2. Display Name: My First PERL Provider

   3. Timeout: 100

   4. Timeout Message: My First PERL Portlet Timed Out

   5. Implementation Style: Web

   6. Provider Login Frequency: Never

   7. URL: http://host.domain:port/servlet/myfirstperl

3. Click OK.

   Note: If the URL that renders your ASP portlet exists on a different domain that Oracle9iAS Portal, go to the Global Setting page within Oracle9iAS Portal and setup your proxy server information. Please review the Oracle9iAS Portal documentation for more information about setting up a proxy server.

4. Now add your new portlet to a page. Take note to view the title and description.

Now that you have successfully built your own PERL portlet using URL services, please look for future articles that will guide you through adding services to your portlet such as session storage, NLS handling, customization, etc. Review the following URL services articles for detailed information about the URL services architecture:

> - A Primer on URL Services
> - Understanding the URL Services Runtime
> - Understanding the provider.xml for URL Services

.

Revision History:

- June 25, 2001.