WebSphere Portal Server and Web Services
Portlets are pluggable components runnung inside a portal’s portlet container, similar to servlets in many aspects. Portlets are written to a portlet API similar to the servlet API. However, portlets run in a portal environment, while servlets run stand-alone in a servlet container. While servlets communicate directly with their clients, portlets are invoked indirectly via the portal application. In order to properly run in the context of a portal, portlets must produce content that is suited for aggregation in larger pages, i.e. portlets should produce markup-fragments adhering to guidelines that assure that the content generated by many different portlets can be aggregated.
When the portal receives a servlet request, it generates and dispatches events for any portlet affected by parameters in the request and then invokes all portlets that have to be displayed trough the portlet invocation interface in a second step (see Figure 7).
Portlet Archive File
Portlet Invocation Interface
e.g. JSPs, Stylesheets, ...
Standard Portlet Service Interfaces
User Info Provider
Figure 7: The Portlet Concept
While portlets must implement the invocation methods required by the Portlet API, internally they may be implemented differently. A pattern that has proven very suitable for portlet programming is the Model-View-Controller pattern. It separates the portlet functionality into a controller receiving incoming requests, invoking commands operating on a model that encapsulates application data and logic and finally calling views for presentation of the results.
Portlets have access to portal related functions and data through Portlet Service Interfaces. These interfaces provide portlets with functions including access to user profile information, persistent per-portlet instance data, action handling, etc. Apart from portal specific functions, portlets can use all the J2EE services that are available to servlets as well as vendor-provided connectors to access back-end data and applications or even services in the Internet.
For easier deployment, portlets can be grouped in Portlet Applications packaged into Portlet Archive files containing a deployment descriptor, Java classes, jar files, and resources.