Delivering Oracle Portal Content Through Java Server Pages

May 29th, 2004 by Mark Rittman

Oracle Portal comes with a useful web interface for building pages out of
regions, items and portlets. If you’re familiar with Oracle Portal and the site
design is not too complicated, you can usually put something together that looks
good and fits within the Portal page structure. But what if you’ve been given a
design built in Dreamweaver or Frontpage and you want to deliver it using Oracle
9iAS and Portal? Maybe you want to take advantage of 9iAS’s speed and
resilience, or maybe you want to include content from Oracle portal into your
website.

With Oracle Portal 1.0.2.2 (the version of Portal that came with the first
release of 9iAS) this was a difficult task as you had to translate the page
design into regions, portlets and content areas. However, with Oracle Portal
9.0.2 and higher, you can convert your HTML pages to JSPs and have 9iAS deliver
these for you, either as external JSPs that run outside of Portal, or as
internal JSPs that are integrated into Oracle Portal. What’s more, you can
reference Oracle Portal portlets in these JSPs, allowing you to integrate Portal
content into your website, and even use Oracle’s Single Sign-On feature to
control user access.

The following example uses Application Server 10g to integrate Portal
portlets into a JSP page, and delivers it through the AS10g mid-tier webserver [Thanks
to Gareth for putting together
the examples]

  1. First, rename your existing HTML files to use the extension .jsp
    instead of .htm or .html
  2. Create a new blank file at $ORACLE_HOME\j2ee\OC4J_Portal\applications\portal\portal\WEB-INF\wwjps.xml
    where $ORACLE_HOME is your Portal
    mid-tier instance

    Within the file, create this XML

    <jps version="1.0">
    <portal name="mtier" default="true">
    <database data-source="jdbc/MyPortal"/>
    <url host="acgdev05.plusdevelopment.co.uk"
    port="7779" path="/pls/portal"/>
    <cookie name="portal" maxAge="-1" path="/"
    />
    <pageGroups>
    <pageGroup name="DWHome" key="welcome1"
    default="false"/>
    <pageGroup name="TOPLEVELSITE" key="welcome1"
    default="true"/>
    <pageGroup name="GH_DEV" key="welcome1"
    default="false"/>
    <pageGroup name="PG_PAYMON" key="welcome1"
    default="false"/>
    </pageGroups>
    </portal>
    </jps>

    Note: The <portal name="mtier"
    default="true">
    is the name of the mid-tier instance
    that contains the Portal application we wish to use portlets from. The <pageGroup
    name="DWHome" key="welcome1"
    default="false"/>
    entries define which pagegroups will
    contain the portlets we wish to use. The MyPortal
    reference I’ll explain in a second.

  3. Locate the file $ORACLE_HOME\j2ee\OC4J_Portal\applications\portal\portal\WEB-INF\web.xml
    where $ORACLE_HOME is your
    Portal mid-tier instance

    This file should contain the following code within the
    <web-app> tag.

    <context-param>
    <param-name>oracle.webdb.service.ConfigLoader</param-name>
    <param-value>/WEB-INF/wwjps.xml</param-value>
    <description>This parameter specifies the location of the JPS
    configuration file</description>
    </context-param>

    Note: In the OC4J_Portal application this code is already present in the
    web.xml file

  4. In the wwjps.xml file (mentioned in step 1) there is a tag to provide
    database connection information about a given portal instance.

    <database data-source="jdbc/MyPortal"/>

    Data-source attribute value is the name of the datasource, which must be
    specified in the data-sources.xml
    file located in the $J2EE_HOME/config
    directory. This file is located in the $ORACLE_HOME\j2ee\OC4J_Portal\config\data-sources.xml

    The following code was inserted into this file for a connection to the
    Infrastructure database:

    <data-source
    class="com.evermind.sql.DriverManagerDataSource"
    name="MyPortal"
    location="jdbc/MyPortal"
    xa-location="jdbc/xa/MyPortal"
    ejb-location="jdbc/MyPortal"
    connection-driver="oracle.jdbc.driver.OracleDriver"
    username="portal"
    password="A5wGWNL7"
    url="jdbc:oracle:thin:@acgdev05.plusdevelopment.co.uk:1521:as10g"
    inactivity-timeout="30"
    />

    The text in bold must be the same as the text in bold in the wwjps.xml
    file.

  5. If you want a Portal page group to be accessible externally then you need
    to allow external access.  To do
    so go the the Page Group Properties  
    Configure  
    JSP Access.  Check the
    "Allow External Access" tickbox and enter the access key.  
    The access key should be the key="welcome1"
    value you used when creating the wwjps.xml
    file in step 1.

     

  6. To add a portlet that can be accessed from our JSP page, use
    Navigator to select the page group you wish to work with, click on the
    ‘Externally Published Portlets’ entry at the bottom of the navigator page,
    then click on the ‘Create Externally Published Portlet’ link. Select a
    portlet you wish to publish and give it a name.

  1. To include a reference to this portlet in your .jsp page,
    open up the page in your HTML editor and add the following JSP tag codes.

    <%@ taglib prefix="portal"
    uri="/WEB-INF/lib/wwjpstag.jar" %>
    <portal:usePortal id="mtier" pagegroup="PG_PAYMON"
    login="false"/>
    <portal:showPortlet name="test_paymon" portal="mtier"
    header="True"/>

  2. Lastly, copy your .JSP pages into the $ORACLE_HOME\j2ee\OC4J_Portal\applications\portal\portal\
    directory, which the ‘htdocs’ equivalent for your now 9ias-delivered
    website.
  3. Assuming your converted HTML
    page is now called index.jsp, you
    can now access your page using the URL http://<host.domain:port/portal/index.jsp

What we’ve done here is convert our HTML pages to JSP pages, include
references to Portal portlets, and delivered the page through Application Server
10g. Oracle refer to these as ‘external JSPs’, and because the pages aren’t
hosted in Portal you’ll have to maintain them outside of Portal. However, you
can also choose to take your JSP page and import it into Portal, making it what
Oracle terms an Internal JSP. To do this:

  1. Create your Portal page group as normal, but when you go to create a new
    page, select ‘JSP’ as your page type.

  1. Then, after naming the page, select the jsp page (from your filesystem, not
    from a URL) to import, and it’ll then be brought in as an internal JSP.

Like external JSPs,
internal JSPs can reference Portal content as well as regular HTML and JSP tags.
So what are the differences between external and internal JSPs?

  • Both internal
    and external JSPs are created outside of Portal using a text editor or HTML
    editor like Dreamweaver or Frontpage

  • Internal JSPs
    are automatically stored in the Portal database, and are managed and secured
    by Portal

  • External JSPs
    are stored outside of Portal (usually in the 9iAS mid-tier file system,
    under the OC4J_PORTAL directory home) and Portal does not provide any file
    management or file security

  • Both internal
    external JSPs can make use of SSO, internal JSPs automatically and external
    JSPs by using login="true"
    in the Portal JSP tags.

  • Generally,
    Internal JSPs are easier to manage and store, whilst external JSPs are more
    flexible and run faster (as they’re not being delivered through Portal).

For more details on delivering Oracle Portal content through
your JSP pages, check out the Oracle document "Oracle
HTTP Server : Integrating Java Server Pages With Oracle 9iAS Portal"

available on OTN.

Comments

  1. Alex Says:

    Mark,
    thank you very much for this useful article.
    I&#8217;m relatively new to Portal and I&#8217;m trying to learn how can I create highly customized (from a UI perspective) pages.
    I think that JSP (or, perhaps, PSP) is the way to go.
    I was following the steps outlined here but, unfortunately, I was unable to make it work: I get a lengthy java Internal Server Error (jdbc/MyPortal not found).
    I&#8217;m probably missing something obvious here: can you help?
    Alessandro
    PS: apologies for my English and for the possibly inappropriate use of your blog (I&#8217;m new to this as well :) )

  2. Alex Says:

    Never mind, I figured it out.
    I had to restart my OC4J server, dopey me!
    Alessandro

  3. Raj Shrestha Says:

    Thank you for the good documentation.
    I also got an Internal Server Error (jdbc/MyPortal not found) error at the end. After I restarted my OC4J_Portal however, I am getting another error as follows:
    java.sql.SQLException: Io exception: Connection refused(DESCRIPTION=(TMP=)(VSNNUM=151000065)(ERR=12505)(ERROR_STACK=(ERROR=(CODE=12505)(EMFI=4))))
    Any idea what this is? I can connect to the database manually using SQLPlus. Anything else I need to do to make it work?
    Thanks much.
    Raj

  4. B P &#187; Oracle Portal JSP Based Pages Says:

    […] NOTE: As some of you might know, I am heavily involved in the use of and development for the Oracle Portal product. Specifically I am working with the Portal 10g product version 10.1.2.* and it’s various componenets. In my recent trolling through Google search results I found the following information on Mark Rittman’s blog. The below is a direct copy from his blog and all credit should be hereby granted to him for the following content. This “re-post” is simply for the purpose of further distributing this info and also creating a version for myself in the unwelcome event that Mark’s site goes defunct or is unavailable. […]

  5. Ramadan Ahmed Says:

    Thank you Very Much, this article helped me so much.

    Now I’m working on OracleAs 10g portal, and it’s not the same. would please help me here ????

    thank you

  6. Mark Rittman Says:

    Hi Ramadan,

    I’m afraid it wasn’t me doing the work with Portal and JSP pages, it was one of my old colleagues from a previous company, so I can’t really help you on how the process now works with OracleAS Portal 10g - sorry. Try the OTN Oracle Portal pages (http://portalstudio.oracle.com/) and the relevant forums (http://www.oracle.com/technology/products/ias/portal/discussion_forums.html) , they’ll probably be the best place to start.

    regards

    Mark