Recent from talks
Contribute something
Nothing was collected or created yet.
Java Portlet Specification
View on WikipediaThis article needs additional citations for verification. (January 2013) |
A Java Portlet Specification defines a contract between portlets and their containers; they provides a convenient programming model for Java portlet developers. It is defined through various Java Specification Requests (JSRs).
Background
[edit]Portlets
[edit]A portlet is a pluggable user interface software component that is managed and displayed in a web portal. A portlet responds to requests from a web client with and generates dynamic content. Some examples of portlet applications are e-mail, weather reports, discussion forums, and news.
Portlet containers
[edit]A portlet is managed by a portlet container, which runs portlets and provides them with the required runtime environment. A portlet container receives requests from the portal to execute requests on the portlets hosted by it.
Specifications
[edit]Portlet standards are platform independent application programming interfaces that are intended to enable software developers to create portlets that can be plugged into any portal supporting the standards. An example is the Java Portlet Specification. A Java portlet resembles a Java Servlet, but produces fragments rather than complete documents, and is not bound by a URL. A Java Portlet Specification (JSR) defines a contract between portlets and the portlet container. JSRs provides a convenient programming model for Java portlet developers.
JSR 168
[edit]The Java Portlet Specification V1.0 was developed under the Java Community Process as Java Specification Request JSR 168, and released in its final form in October 2003.[1]
The Java Portlet Specification V1.0 introduces the basic portlet programming model with:
- two phases of action processing and rendering in order to support the Model–View–Controller pattern.
- portlet modes, enabling the portal to advise the portlet what task it should perform and what content it should generate
- window states, indicating the amount of portal page space that will be assigned to the content generated by the portlet
- portlet data model, allowing the portlet to store view information in the render parameters, session related information in the portlet session and per user persistent data in the portlet preferences
- a packaging format in order to group different portlets and other Java EE artifacts needed by these portlets into one portlet application which can be deployed on the portal server.
- Portal development as a way to integrate the different web-based applications for supporting deliveries of information and services.
Portlet Catalog
[edit]- Initially Java portal vendors had their own portlet development framework thus those portlets were confined to specific portal servers and couldn't be deployed to the rest of the Java portals. After JSR 168 inception, Java portlets may be deployed on any Java portal servers adhering to JSR 168 specifications.
- A Portlets Catalog is a set of portlets that are ready-to-use components for enterprise portals. For those who want to adopt portals certainly need many and variety of portlets to deploy and run. Here Portlets catalog are of use.
- A JSR 168 portlets catalog makes sure that portlets under this catalog may run on any standards–compliant Java portal server. Types of portlet solution (vertical domains and technology) like collaboration, social networking, community, content management, utility, calendaring, HRM all are available in these catalogs.
- There are many open source and commercial Portlets Catalog available but JSR 168 based solutions are rare.
- JSR 168 specifications offer suitability to the developers to reuse the code to maintain a set of JSR 168 compliant portlets. For deployers, it's easy to keep a single set of solution and deploy it on many.
JSR 286
[edit]JSR-286 is the Java Portlet Specification v2.0 as developed under the JCP and created in alignment with the updated version 2.0 of WSRP. It was released in June 2008.[2] It was developed to improve on the short-comings of the version 1.0 specification, JSR-168. Some of its major features include:[3]
- Inter-Portlet Communication through events and public render parameters
- Serving dynamically generated resources directly through portlets
- Serving AJAX or JSON data directly through portlets
- Introduction of portlet filters and listeners
JSR 362
[edit]JSR-362 is the Java Portlet Specification v3.0 and was released in April 2017.[4] Some of its major features include:[5]
- Resource Dependencies
- Explicit Render State
- CDI 1.2 Integration
- Servlet 3.1 Alignment
- Portlet Hub & XHR IPC
- FacesBridge Integration via JSR 378[6]
See also
[edit]References
[edit]- ^ "JSR 168". JCP.
- ^ "JSR 286: Portlet Specification 2.0".
- ^ Hepper, Stefan (18 March 2008). "What's new in the Java Portlet Specification V2.0 (JSR 286)?". IBM.
- ^ "JSR 362: Portlet Specification 3.0".
- ^ Nicklous, Martin (Scott) (September 2016). "Portlet Specification 3.0 is Here!" (PDF). IBM.
- ^ "The Java Community Process(SM) Program - JSRs: Java Specification Requests - detail JSR# 378". www.jcp.org.
External links
[edit]- JSR 301 (Portlet 1.0 Bridge for JavaServer Faces 1.2 Specification)
- JSR 329 (Portlet 2.0 Bridge for JSF 1.2 Specification)
- JSR 168 Open Source Reference Implementation at Apache
- Open source JSR 168/WSRP community at java.net
Java Portlet Specification
View on GrokipediaOverview
Definition and Purpose
The Java Portlet Specification is a standard developed through the Java Community Process (JCP) that defines application programming interfaces (APIs) for portlets, which are pluggable user interface components designed to generate fragments of markup content for aggregation and composition within a portal page.[5] These portlets function as modular Java web components, enabling developers to create dynamic, reusable content pieces that can be integrated into larger portal applications.[1] The primary purpose of the specification is to enable the integration of reusable and dynamic content in enterprise portal environments, supporting personalization of user experiences and the aggregation of multiple applications—such as email clients, news feeds, and productivity tools—into a unified interface.[5] By standardizing the deployment and management of portlets across compliant portal servers, it facilitates seamless content delivery and interoperability in distributed systems.[1] Unlike Java servlets, which typically generate complete web pages in response to HTTP requests, portlets produce only markup fragments and adhere to a defined contract with the portlet container for request handling and lifecycle management, making them optimized for portal-based compositions.[5] Portlet containers serve as the runtime environment that orchestrates these components within a portal page.[1] Key benefits of the specification include standardization for enhanced interoperability, allowing portlets to be developed once and deployed across multiple portal vendors without proprietary adaptations, and strong alignment with the broader Java EE (now Jakarta EE) ecosystem for robust enterprise application development.[1] This promotes efficiency for developers, independent software vendors, and end users by broadening the availability of portable portal applications.[5]Historical Development
The Java Portlet Specification began with the proposal and approval of JSR 168 by the Java Community Process (JCP) initiated with the JSR Review Ballot in January 2002, culminating in its final release on October 27, 2003.[5] This inaugural standard emerged to resolve the interoperability challenges posed by proprietary portal technologies, enabling portable portlet development across compliant containers.[5] Building on this foundation, JSR 286 was proposed in November 2005 and released in June 2008 as Portlet Specification 2.0, following final approval in early 2008, addressing limitations identified in version 1.0 through community feedback while incorporating support for contemporary web technologies such as AJAX.[6] The update aimed to enhance portlet capabilities without breaking backward compatibility, fostering broader adoption in enterprise environments.[6] JSR 362 followed, proposed in March 2013 and finalized in April 2017 as Portlet Specification 3.0, integrating advancements from Java EE including Contexts and Dependency Injection (CDI) and Servlet 3.1 to modernize the framework for evolving web and mobile paradigms.[3] In September 2017, Oracle announced the donation of Java EE to the Eclipse Foundation, prompting the rebranding to Jakarta EE and necessitating namespace transitions from javax to jakarta across specifications, including portlets, with ongoing stewardship under Eclipse.[4] As of November 2025, the transition to Jakarta Portlet 4.0 progresses with initial API specifications released in early 2025 following its creation review in April 2025 and API migration in May 2025; Jakarta EE 11 was released on June 26, 2025, though the complete Jakarta Portlet 4.0 specification continues development to align with the Jakarta EE 11 platform.[7]Fundamental Concepts
Portlets
A portlet serves as the fundamental building block in the Java Portlet Specification, functioning as a pluggable Java web component that generates dynamic content fragments for aggregation within a portal page. It is implemented as a Java class adhering to thejavax.portlet.Portlet interface, which outlines the essential contract for processing requests and producing responses in a standardized manner. To streamline development, portlets commonly extend the javax.portlet.GenericPortlet abstract class, which supplies default implementations for lifecycle methods and handles common tasks like request dispatching based on portlet modes.[1]
Portlets are bundled into web application resource (WAR) files for deployment, incorporating the compiled classes, static resources, and a required portlet.xml deployment descriptor file that configures the portlet application. This descriptor defines critical metadata for each portlet, such as localized display names, supported portlet modes (e.g., view, edit, help), and initialization parameters passed to the portlet's init method at startup. It also specifies security constraints to implement role-based access control, restricting access to portlet resources based on user roles defined in the portal environment.[1]
State management in portlets relies on distinct data models to balance statelessness with user personalization. Render parameters, encapsulated in RenderRequest, provide a read-only mechanism for passing state information across render requests, ensuring consistent view generation without server-side persistence. Portlet preferences, managed via the PortletPreferences interface, allow for user-specific, persistent configurations stored in a backend repository, modifiable through edit mode. Session attributes, stored in PortletSession, support temporary state across multiple requests and enable inter-portlet communication within the same user session.[1]
A representative example is a basic "Hello World" portlet that extends GenericPortlet and overrides the doView method to produce a simple HTML fragment. The implementation sets the response content type to text/[html](/page/HTML) and outputs markup like:
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/[html](/page/HTML)");
PrintWriter out = response.getWriter();
out.println("<div class=\"portlet-section-body\">Hello, World!</div>");
}
public void doView(RenderRequest request, RenderResponse response)
throws PortletException, IOException {
response.setContentType("text/[html](/page/HTML)");
PrintWriter out = response.getWriter();
out.println("<div class=\"portlet-section-body\">Hello, World!</div>");
}
Portlet Containers
A portlet container is a Java EE-compliant server component that provides the runtime environment for executing and managing portlets, analogous to a servlet container for servlets. It is integrated into application servers such as Apache Tomcat via extensions like Apache Pluto or embedded within full portal platforms like Liferay, where it hosts portlet applications to generate dynamic content for portal pages.[9][5][10] The primary responsibilities of a portlet container include aggregating requests from multiple portlets to compose a single portal page, dispatching incoming HTTP requests to the appropriate portlets, and enforcing the portlet contract defined by the specification. This involves managing portlet instances, providing access to shared resources, and ensuring that portlets adhere to the defined APIs for content generation and interaction. For instance, when a user accesses a portal page, the container coordinates the rendering of fragments from various portlets into a cohesive response.[5][11] To ensure compliance, a portlet container must fully implement all APIs outlined in the Java Portlet Specification, including support for deploying portlet applications as standard Web Application Archive (WAR) files containing portlet deployment descriptors. It also manages portlet contexts, which encapsulate the environment for a specific portlet application, providing configuration data, initialization parameters, and resource access similar to servlet contexts but tailored for portal aggregation. Compliance is verified through tools like the Portlet Technology Compatibility Kit (TCK).[5][9] Notable implementations include Apache Pluto, the official reference implementation that demonstrates the specification's requirements and serves as a basis for testing. Commercial examples encompass HCL Digital Experience (formerly IBM WebSphere Portal), which integrates the container within its enterprise portal framework with version 9.5 current as of 2025, and Oracle WebCenter, offering advanced composition and security features built on the standard.[9][11][12] Unlike servlet containers, which handle complete HTTP responses for standalone web applications, portlet containers support portal-specific features such as page composition from multiple portlet fragments, multi-portlet coordination via events, and rendering in isolated modes without direct control over the full HTTP response. This enables reusable UI components within aggregated portal environments rather than independent pages.[11]Portlet Lifecycle and Modes
The Java Portlet Specification defines a lifecycle for portlets that governs their execution within a portlet container, ensuring consistent management of resources and state changes. The lifecycle begins with theinit(PortletConfig config) method, which the container invokes once after instantiating the portlet to perform initialization tasks such as setting up resources or loading configurations.[2] Following initialization, the portlet enters an active phase where it processes requests, and it concludes with the destroy() method, called by the container to release resources and clean up state before the portlet instance is removed from service.[2] This lifecycle model, introduced in JSR 168, supports the deployment of portlets as reusable components in portal environments.[5]
Central to request handling is a multi-phase model for processing and rendering, expanded from the initial two phases in Portlet 1.0. The action phase, via processAction(ActionRequest request, ActionResponse response), handles user interactions like form submissions to update state, set parameters, or change modes without generating output. The event phase, introduced in Portlet 2.0 (JSR 286), uses processEvent(EventRequest request, EventResponse response) for inter-portlet communication through events and public render parameters, enabling coordination across portlets. The render phase invokes render(RenderRequest request, RenderResponse response) to generate markup based on the current state. Additionally, the resource phase, also from Portlet 2.0, employs serveResource(ResourceRequest request, ResourceResponse response) for serving dynamic resources such as images, scripts, or AJAX responses without full page rendering. This model ensures consistent portal page aggregation.[2][1]
Portlet modes define the functional state of a portlet during rendering, indicating the type of content or interaction it provides. The specification mandates support for the view mode, where the portlet generates its primary markup reflecting the current state, such as interactive screens or static content.[14] Optional modes include edit, for customizing portlet behavior like setting preferences, and help, for displaying assistance information such as documentation or tooltips.[14] Developers can define custom modes beyond these standards, though support depends on the portal implementation; unsupported modes are ignored during processing.[14] Modes are typically switched via action requests and influence the rendering logic in the render method.[15]
Window states control the visual presentation and space allocation of a portlet window on the portal page, affecting how content is rendered. The normal state represents the default configuration, where the portlet shares the page with others and limits output to accommodate shared display space.[16] In the maximized state, the portlet expands to occupy more or all available space, enabling richer or fuller content presentation.[16] The minimized state restricts the portlet to minimal or no content output, typically showing only the title bar.[16] These states can be altered programmatically during the action phase and are standardized in JSR 168 to promote interoperability across portals.[5]
In practice, the lifecycle and modes integrate through a typical flow: a user interaction triggers an action or event request, where state updates occur (e.g., saving form data or signaling other portlets). The container then invokes render or resource phases for affected portlets, producing the updated view in the appropriate mode and window state. This ensures thread-safe, aggregated rendering without concurrent modifications.[15][2]
Evolution of Specifications
JSR 168: Portlet Specification 1.0
The JSR 168, formally known as the Portlet Specification version 1.0, was finalized and released on October 27, 2003, through the Java Community Process (JCP).[5] The expert group, co-led by Sun Microsystems and IBM, included representatives from organizations such as Apache Software Foundation, BEA Systems, Oracle, and SAP to develop a standardized API for Java-based portlets.[5] This specification established the foundational contract between portlets and their containers, enabling interoperability across different portal servers while aligning with the Servlet Specification 2.3 and JSP 1.2 standards.[5] At its core, JSR 168 introduced a two-phase rendering model to support the Model-View-Controller (MVC) pattern in portlet development. In this model, the action processing phase handles user interactions and updates the portlet's state without generating markup, followed by the rendering phase where the portlet produces content fragments for aggregation into a portal page.[1] Portlets could operate in different portlet modes to manage various user interactions: view for displaying primary content, edit for user customization, and help for providing assistance information.[5] Additionally, window states controlled the portlet's space allocation on the page, with standard states including normal (shared space with other portlets), minimized (reduced to a title bar), and maximized (expanded to fill the page), along with defined transitions between them.[5] Data handling in JSR 168 emphasized persistent and transient state management. The Portlet Preferences API allowed developers to store and retrieve user-specific settings on a per-portlet-instance basis, enabling personalization such as layout adjustments or content filters that persisted across sessions.[5] Render parameters facilitated passing state information between the action and rendering phases or across requests within the same portlet, ensuring stateless operation while maintaining context for dynamic content generation.[1] Deployment followed a standardized approach using aportlet.xml deployment descriptor to configure portlet definitions, including modes, states, init parameters, and supported content types. Portlets were packaged as Web Application Archive (WAR) files, integrating seamlessly with J2EE application servers for distribution and deployment in compliant containers.[5]
While JSR 168 provided a robust basic model for portlet development, it lacked support for inter-portlet communication mechanisms and dynamic serving of resources like images or scripts directly from portlets, limitations that influenced subsequent enhancements.[1] The reference implementation for this specification was Apache Pluto 1.0, an open-source portlet container that demonstrated compliance and served as a testing ground for developers.[9]
JSR 286: Portlet Specification 2.0
The Java Portlet Specification 2.0, formalized under JSR 286, was approved as a final release on June 12, 2008, by the Java Community Process (JCP).[6] This version maintains binary compatibility with the preceding JSR 168 (Portlet Specification 1.0), ensuring that existing portlets could continue to function without modification while introducing enhancements for improved interoperability and integration with emerging web technologies.[17] The specification's primary goals included aligning the portlet API with Java EE 5 standards and Web Services for Remote Portlets (WSRP) 2.0, thereby facilitating better coordination among portlets and support for remote syndication in distributed environments.[6] A major advancement in JSR 286 is the introduction of inter-portlet communication mechanisms, including events and public render parameters, which enable portlets to coordinate actions and share state without direct coupling.[18] Events provide a publish-subscribe model where portlets can declare and process typed events during the action phase, allowing responses to state changes across portlets or even web applications, with processing completing before rendering begins to maintain consistency.[18] Public render parameters extend this by permitting shared, bookmarkable parameters (e.g., via HTTP GET) defined in the deployment descriptor, supporting coordination such as filtering search results across multiple portlets on the same page.[18] Additionally, the ServeResource method allows portlets to serve dynamic resources like AJAX responses or JSON data independently of full page renders, enhancing support for asynchronous interactions with configurable caching levels (FULL, PORTLET, or PAGE).[18] Further enhancements include portlet filters, which intercept and modify requests similar to servlet filters, declared via deployment descriptors for tasks like logging or compression.[18] Container runtime options, such as XML escaping configurations, provide finer control over portlet behavior, while portlet listeners enable notifications for lifecycle events like mode changes.[18] Preference handling was improved with support for validators to ensure data integrity during storage and retrieval.[17] Security was bolstered through propagation of the security context to resource serving and alignment with Java EE 5's role-based access controls, ensuring protected access to dynamic content.[6] These features collectively advanced modern web integration, such as Web 2.0-style interactions. JSR 286 saw widespread adoption in enterprise portals, powering asynchronous and event-driven architectures in implementations like Apache Pluto (the reference implementation) and commercial servers from vendors including Oracle and IBM, where it remains a foundational standard for Java-based portal development.[6][9]JSR 362: Portlet Specification 3.0
JSR 362, known as the Portlet Specification 3.0, was finalized and released on April 12, 2017, by the Java Community Process (JCP) to update the portlet standard in alignment with advancements in Java EE 7 technologies. This version addresses limitations in the preceding JSR 286 (Portlet 2.0) by enhancing integration with contemporary enterprise Java standards, such as improved dependency injection and asynchronous processing, thereby boosting developer productivity in building modular web applications. The specification maintains full backward compatibility with Portlet 2.0 APIs, allowing existing portlets to deploy on 3.0 containers without modification, while introducing targeted deprecations for future evolution.[3][19] A major enhancement is the integration of Contexts and Dependency Injection (CDI) 1.2, enabling dependency injection directly into portlet classes, filters, listeners, and even asynchronous threads. This includes new custom scopes—@PortletSessionScoped for session-wide access, @PortletRequestScoped for request-specific instances, and @RenderStateScoped for managing render-phase state across requests—to simplify resource management and promote reusable components. Additionally, the specification aligns with Servlet 3.1 by adding asynchronous support for resource requests through the PortletAsyncContext interface, which facilitates handling long-running operations without blocking the main thread, thus improving scalability in enterprise portals.[19][3] Resource handling sees significant improvements, particularly for client-side dependencies like JavaScript libraries and CSS stylesheets. The @Dependency annotation allows portlets to declare external resources that the container automatically serves and manages, reducing boilerplate code for loading shared assets across portlets. Explicit render state management is further refined with annotations such as @HeaderMethod, @RenderMethod, and @ServeResourceMethod, which support flexible method signatures and separation of concerns by allowing these methods to reside in distinct classes, easing maintenance in complex applications.[19] Inter-portlet communication (IPC) advances through the introduction of the Portlet Hub API, a client-side JavaScript interface that enables asynchronous interactions via XMLHttpRequest (XHR), building briefly on the server-side event system from JSR 286 to support dynamic updates without full page reloads. This API allows reading and writing render parameters, executing actions, and generating resource URLs in an Ajax-friendly manner, enhancing user experience in composite portals. Complementing this, integration with FacesBridge 2.0 (JSR 378) leverages Portlet 3.0's new HEADER_PHASE in the portlet lifecycle to better support JavaServer Faces (JSF) 2.2 portlets, ensuring seamless bridging for JSF-based components within portlet environments.[19][3][20] To streamline development, Portlet 3.0 introduces annotation-based configuration via @PortletApplication and @PortletConfiguration, eliminating the need for verbose deployment descriptors in many cases and aligning with modern Java EE practices for declarative setup. These changes collectively focus on developer productivity by reducing configuration overhead and enhancing modularity, while preserving the core portlet contract for enterprise-grade portal applications.[19][3]Transition to Jakarta EE: Portlet 4.0
Following Oracle's announcement in September 2017 to transfer stewardship of Java EE to the Eclipse Foundation, the platform underwent a rebranding to Jakarta EE, beginning with version 9 in 2020, which introduced the namespace shift fromjavax.* to jakarta.* to enable open governance and future evolution under the Eclipse Foundation.[21]
Jakarta Portlet 4.0 represents the migration of the JSR 362 APIs—serving as the baseline for Portlet 3.0—from the javax.portlet.* namespace to jakarta.portlet.*, with an initial emphasis on maintaining compatibility rather than introducing major new features, adhering to semantic versioning principles to support incremental updates.[7][22]
The development timeline for Jakarta Portlet 4.0 began with a project proposal submitted to the Eclipse Foundation on March 24, 2025, followed by a successful creation review on April 16, 2025, marking the official start of the specification project under Eclipse's processes.[22][23] As of November 2025, the full specification remains under active development, with early API artifacts, such as Maven dependencies, made available to facilitate testing and integration.[7][24]
This transition is essential for ensuring compliance with future Jakarta EE releases, notably impacting portal implementations like Liferay DXP, which began adopting Jakarta EE 10— including Portlet 4.0 support—starting with its 2025.Q3 release to leverage enhanced security and modularity.[25][26] Backward compatibility for legacy applications is supported through bridging mechanisms that allow mixed javax and jakarta environments during phased migrations.[27] However, challenges include updating dependencies in existing portlet applications to resolve namespace conflicts and ensuring alignment with aligned specifications, such as Jakarta Servlet 6.0, which shares similar migration requirements.[28]References
- https://jcp.org/en/jsr/detail?id=[168](/page/168)
