Introducing Java Portlet Specifications: JSR 168 and JSR 286

   
March 16, 2007  
link

Portlets are Web-based components managed by portlet containers that supply dynamic content. Portals employ portlets as pluggable user-interface componentsPH*PH*PH\u2014PH*PH*PHa presentation layerPH*PH*PH\u2014PH*PH*PHfor information systems. The Java Portlet Specification achieves interoperability among portlets and portals by defining the APIs for portlets and by standardizing the rules for preferences, user data, portlet requests and responses, deployment, packaging, and security. Java Portlet Specification 1.0, Java Specification Request (JSR) 168, was released in October 2003.

In February 2006, the JSR 286 Expert Group was formed to start work on Java Portlet Specification 2.0. When that is finalized, backward compatibility will be in place: JSR 168 portlets will be able to run seamlessly in JSR 286 portlet containers. No recompilation will be necessary.

This article spotlights JSR 168 and the associated software, Portlet Container 1.0 and the NetBeans Portlet Plug-in. Also described are sample portlets and JSR 286 in its draft state.

Contents
 
JSR 168, Portlet Container, and NetBeans Portlet Plug-in
JSR 168-Compliant Sample Portlets
JSR 286
References
 
JSR 168, Portlet Container, and NetBeans Portlet Plug-in

In the pre-JSR 168 days, you had to develop and maintain a separate version of your portlet that complied with the vendor-specific portlet API for each and every vendor portal. The related tasks were time-consuming, aggravating, and cumbersome. Moreover, to the detriment of the end users, ISVs, developers, and vendors, that scenario meant that only a limited number of applications were available through only a few portals.

JSR 168 brought a world of a difference: By adhering to the standards, you can build portlets that can run in portals, irrespective of their vendors. Hence, no more hassles with the requirements that vary according to vendors. ThatPH*PH*PH\u2019PH*PH*PHs a win-win situation for all.

With the release of Sun Java System Portal Server (henceforth, Portal Server) 6.2, Sun became one of the first vendors that supported JSR 168. Portal System Server 7.0, the latest portal server release from Sun, is free for download and deployment.

To send questions or comments on JSR 168, write its interest alias.

Java Community Process
JSR 168 was born of the Java Community Process (JCP), an open, international, community-based organization that coordinates the development of Java technology standards, reference implementations, and technology compatibility kits. As coleader of the JCP, Sun also serves as the editor of JSR 168 and developer of the Test Compatibility Kit (TCK). Since its inception, JSR 168 has received strong and enthusiastic industry support.

See the technical paper, Introduction to JSR 168: The Java Portlet Specification (PDF) , which describes the benefits of JSR 168 and introduces the portlet programming model through the code of a robust portlet example.

Portlet Container
Portlet Container 1.0, developed through the Enterprise-Class Portlet Container Open Source Project, not only delivers an implementation of the JSR 168 Portlet Container but also contains a portlet driverPH*PH*PH\u2014PH*PH*PHa lightweight rendering environment. As part of Java Application Platform SDK Update 2, Portlet Container 1.0 is integrated with Sun Java System Application Server Platform Edition (PE) 9.0.

The implementation of the JSR 168 Portlet Container, which originated from Portal Server 7.0, offers capabilities well beyond JSR 168. In the future, the Enterprise-Class Portlet Container Open Source Project will deliver an enterprise implementation of JSR 286.

Portal Open Source Project
Furthermore, the Enterprise-Class Portlet Container Open Source Project is part of the Portal Open Source Project, which includes development projects for other portal-related components. Examples are:

  • Implementation of a Web Services for Remote Portlets (WSRP) producer and a WSRP consumer
     
  • Portal aggregation and administration framework
     
  • JavaServer Faces technology-based portlet bridge
     
  • Community and collaboration framework
     
  • The Portlet Repository

For details, see Open-Source Portal Initiative at Sun, Part 1: Overview .

NetBeans Portlet Plug-in
The NetBeans Portlet Plug-in is a key component for generating and deploying JSR 168 portlets on the Portlet Container. For details, see a related blog.

 

Back to top

JSR 168-Compliant Sample Portlets

Check out a few sample portlets that demonstrate the benefits of adopting JSR 168. But first, download Java Application Platform SDK Update 2 for the components for developing, testing, and deploying JSR 168 portlets, namely—

  • NetBeans 5.5 IDE
     
  • NetBeans Portlet Plug-in, which you install in the NetBeans Update Center wizard
     
  • Sun Java System Application Server PE 9.0, which includes Portlet Container 1.0

A Stand-alone Sample
Now download the Weather Portlet, a stand-alone sample that is prebuilt with the NetBeans Portlet Plug-in. This sample provides the complete source code for the example that is described in the technical paper mentioned earlier.

As its name implies, the Weather Portlet displays the current temperature in a U.S. location denoted by a user-specified zip code. Also, as a demonstration of how the Java APIs for XML-Based Remote Procedure Call (JAX-RPC) connect to Web services, this sample obtains the temperature from the weather Web service of XMethods.

To run the Weather Portlet:

  1. Unzip the weathersample.zip file in any location on your file system.
     
  2. Open the project file in the NetBeans 5.5 IDE.
     
    Recall that the IDE contains the NetBeans Portlet Plug-in.

Alternatively, run the Weather Portlet sample in another IDE that supports JSR 168 portlets. Be sure to supply the appropriate environment- specific project files.

Samples From the Open Source Portlet Repository

The Open Source Portlet Repository (henceforth, the repository), a java.net project, manages and build portlet samples with Maven. Because the NetBeans IDE also supports Maven projects through the NetBeans Maven2 Plug-in, you can build and run the samples as Maven projects. Alternatively, manually create the NetBeans project.

Currently, the repository offers numerous sample portlets, among them the following:

  • Bookmarks Portlet — Adds Web-site bookmarks to your Portal Server desktop.
     
  • Notepad Portlet — Creates personal notes and then organizes them in categories. An important benefit is that other portal users cannot access those notes.
     
  • Blog Portlet — Manages Weblogs from a portal according to the Atom Publishing Protocol (APP).
     
  • Ajax Portlet — Demonstrates how to apply Ajax, a technology that includes but is not limited to Asynchronous JavaScript and XML, to build JSR 168 portlets and the related challenges. This portlet is built with the Dojo Toolkit.
     
  • Flickr Portlet — Enables access to Flickr photos.
     
  • iFrame Portlet — Displays a Web page in iFrame. This portlet demonstrates how to build portlets with iFrame technology.
     
  • Java Authentication and Authorization Service (JAAS) Portlet — Authenticates users against a plain-text password file with the JAAS APIs.
     
  • YoutubePortlet and SingleVideoPortlet — Displays videos.

Here is a screen shot that shows those portlets at a glance:

 
 
Figure 1: Sample Portlets
 

For details on the repository, see the article Open-Source Portal Initiative at Sun, Part 2: Portlet Repository .

 

Back to top

JSR 286

Since its release in 2003, JSR 168 has gone through many real-life tests in portal development and deployment. For all that the community has identified "gaps," standards take time to evolve and become available to the public. Meanwhile, many portal vendors have been filling those gaps with their own custom solutions, which unfortunately cause portlets to be not portable.

To date, one of the most clamored-for standards is that for interportlet communication. The only JSR 168 provision that serves that purpose is the portlet session.

Currently, the OASIS Technical Committee is finalizing WSRP Specification 2.0, a complementary standard. In the past, WSRP Specification 1.0 and Java Portlet Specification 1.0 were developed hand in hand. Not surprisingly, the JSR 286 Expert Group has placed a high priority on aligning Java Portlet Specification 2.0 with WSRP 2.0.

The first draft of JSR 286 brings to the Java portlets all the key capabilities introduced by WSRP 2.0. Examples are—

  • Events — Enable portlets to communicate with each other through sending and receiving events.
     
  • Shared render parameters — Enable portlets to specify which render parameters they can share with other portlets.
     
  • Resource serving — Enables portlets to serve resources within the portlet context.

In addition, the first JSR 286 draft defines the portlet filters, with which portlets can, on the fly, transform the content of portlet requests and responses.

Stay tuned for the many enhancements in Java Portlet Specification 2.0. For example, you will be able to take advantage of the Java Portlet Specification 1.0 caching model and reap support for asynchronous technologies, such as Ajax.

To send questions or comments on JSR 286, write its interest alias.

 

Back to top

References
 

Back to top

Rate and Review
Tell us what you think of the content of this page.
Excellent   Good   Fair   Poor  
Comments:
Your email address (no reply is possible without an address):
Sun Privacy Policy

Note: We are not able to respond to all submitted comments.
Left Curve
Java SDKs and Tools
Right Curve
Left Curve
Java Resources
Right Curve