Tuesday, November 11, 2008

What are the Differences between Portlet and Servlet?

Portlets have many similarities with Servlets and much of the Portlet specification is based on Servlet specification. Both of them share several similarities like being container managed, Request/Response paradigm etc. Here in this section I will discuss the differences between these two.

Portlets only generate markup fragments, not complete documents. The Portal
aggregates portlet markup fragments into a complete portal page

A Portal is made up of various portlets which are pluggable UI components representing different applications. When a portlet finishes generating the content, the output in not an entire html document. Rather it is a part usually in form of
. Each of the portlet in the portal generates similar fragments which is then aggregated by the portal server to generate the entire page.

Portlets can only be invoked through URLs constructed via the portlet API.

Url through which portlet is invoked is not under the complete control of the developer. It is generated by the Portal server. The reason for this is there can be several portlets in a page and they can only be accessed via the Portal. Therefore Portal creates the urls for accessing the portlets.

Here is one example url on IBM portal server. http://122.168.192.199/wps/myportal/!ut/p/c1/04_SB8K8xLLM9MSSzPy8xBz9CP0os3hPvwDTMG93QwMDQzNLAyMnXx__EFcnIwMDA6B8pFm8n79RqJuJp6GhhZmroYGRmYeJk0-Yp4G7izExug1wAEcDArrDQa7FbztIHo_5fh75uan6BbmhEQZZJooAuf06PA!!/dl2/d1/L2dJQSEvUUt3QS9ZQnB3LzZfSU5QNVZLRzEwR0c4ODAyQkk3NDZVOTIwMDA!

Web clients interact with portlets through a portal system

This point is extension of last point. In case of Servlets they can be accessed directly using a url. Servlets reside on servlet container which is called by the webserver.

In case of portlets, request reaches the Portal server which then sends the request to the portlet via the portlet container.

Portlets have a more refined request handling, action requests, event request,
resource requests and render requests

Portlets have separation of layers for handling the user action and then rendering the content. Whenever user clicks an action on a portlet action request is generated where business logic is performed, and for creating the fragment which will be displayed, render request is generated. When user clicks action on one of the portlet on the portal, for that portlet both action request and render request is generated, and for other portlets only render request is generated.

Portlets have predefined portlet modes and window states that indicate the
function the portlet is performing and the amount of real state in the portal page.

Servlet always run in same mode as there is no separate mode. In a portlet there are several possible modes in which the portlet can exist. For example, View, Edit help mode etc. Based on the selected mode different actions can be performed on the portlet. For example edit mode can be used to provide configuration information of an email portlet and the view mode to read the emails. Access to modes can be restricted base on the user role. A portlet can be minimized or maximized like the windows.

Portlets can exist many times in a portal page.

Administrator can create several instances of a portlet and place them in multiple places as appropriate for the business. For example if the business scenario demands that user should be able to see his email on any page of the Portal then administrator can create instances of the portlet and place them in all the pages the user has access to.

Monday, November 10, 2008

What is the difference between Portlet container and Portal?

Portal

  • Manages the request/response to a portlet. Portal receives the request on behalf of a portlet, sends it to portlet and sends back the response to the user.
  • Handles authentication of the users.
  • Generates a document based on the fragments from the different portlets in the page. This is called content aggregation.
  • Makes sure user is provided the content (Portlets) for which user is authorized. For example some users may not be authorized to view a portlet or edit a portlet and these are taken care of by the Portal.

Portlet Container

  • Provides runtime environment and manages the Lifecycle of the Portlet like a Servlet container manages the lifecycle of a Servlet.
  • Portlet container provides persistent storage for portlet preferences.
  • Portlet container receives requests from Portal if a portlet needs to fulfill a request and the portlet container passes it on to required portlet.
  • After obtaining the response from the Portlet, Portlet container sends the fragment of the portlet to the Portal for aggregation.

Monday, November 3, 2008

What are JSR 168 and JSR 286?

A) Names of latest Java Servlet Containers?
B) Specification for Java Portlet Specification Development?

Answer : B.

JSR 168 is specification which explains the contract between Portlet Container and Portlets. It explains what are the responsibilities and services which a Portlet developer can expect when developing Java based portlets.

JSR 286 was created to fill the gaps in JSR 168. It documents enhancement in the existing specification and the containers supporting JSR 286 specification must provide certain extra services like inter portlet communication and AJAX support.