n increasing number of web applications built today use portal technology. A portal
is a web application that typically provides services such as personalization, single sign-on, and content aggregation from different sources. Aggregation is the action of integrating content from different sources within a web page.
Portlets are the visible active components that users see within their portal pages. In the simplest terms, for Java-based portals, a portlet
is a Java servlet that operates inside a portal. Figure 1
shows an example portal page with a portlet on it. A Portal Web Server provides a portlet container that serves portlets to users.
|Figure 1. A Portal Page with a Portlet: Here's a simple portlet container containing a portlet.|
Commercially available Java Portal Web Servers include BEA, IBM, and Oracle, but there are also many open source Java Portal Web Servers such as Liferay, Pluto, Stringbeans, and JBoss Portal. Most of these Java Portal Web Servers have tools that allow you to build portlets. In the early days of portals, 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. Maintaining separate vendor-specific versions was time consuming, aggravating, and cumbersome, and limited the availability of generic, cross-server portlets.
Java Specifiction Request #168 (JSR 168
) has solved this vendor-specific portlet configuration problem. By adhering to the standards, you can now build portlets that can run in portals irrespective of their vendors. Most Java Portal Web Servers support the JSR 168 specification.
|Figure 2. Interacting with a Web Service: The diagram illustrates how the sample portlet interacts with an external web service.|
This article concentrates on the presentation and service layers of a Portal Web Server (see Figure 2
). The presentation layer interacts with services to aggregate data from different sources. These services are typically defined in the service layer and are part of any Service-Oriented Architecture (SOA) implemented in a portal. An easy way to implement SOA architecture is through web services, which Gartner defines as, "Web services are software components that employ one or more of three technologies—SOAP, WSDL, and UDDI—to perform distributed computing."
This article will first describe how to write a JSR 168 portlet, and then cover how to implement a service within a portlet. You can use any web service provider; however, this article uses a Xignite service
. Figure 2
illustrates how the portlet in the presentation layer interacts with a financial service in the service layer to get data. The Financial Service uses web services to access Xignite Financial Web Services.
|Editor's Note: This article was prepared and contributed by employees of NuWave and Xignite for DevX. We felt it had sufficient technical merit to publish on DevX. NuWave Solutions is a professional services firm specializing in solving business problems through innovative technology solutions. Xignite is a leading pure-play provider of financial web services for mission-critical corporate applications.