Saturday, May 23, 2009

How a Portlet is different from a Servlet ?

Here I would like to publish a small discussion on portlet and servlet, hope that will help you to make a better understanding on portal technology.

The differences between the portlet and servlet are:
1. Servlets can provide the content to complete web pages, whereas portlets only provide fragments. And these fragments are then aggregated to form a complete web page by the portal.
2. The user cannot access a portlet directly using a URL in the way that a servlet is accessed. Instead, the URL points to the page containing all of the portlets on single page.
3. Portlets aren’t allowed to generated HTML code that contains tags such as base, body, frame, frameset, head, title or html . Note: Here the iframe tag can be used with caution.
4. The communication between the web client and the portlets is performed through the portal.
5. Portlet allows to manipulate the portlets’ window states or portlet modes by providing the buttons or controls.

The similarities between the servlet and portlet:
1. Servlets and portlets are web based components that utilize Java for their implementation.
2. Portlets are managed by a portlet container similar to a servlet container.
3. Both of these components generate content, which can be static or dynamic.
4. Both portlets and servlets have a lifecycle that is controlled by the container.
5. The client/server model is used for both servlets and portlets.
6. The packaging and deployment are essentially the same.
7. The manner in which the classes are loaded and the class loaders that perform the work are also the same.
8. Lifecycle management is similar.
9. The Request and Response semantics are also similar.

There are several things that servlets are allowed to do, but portlets are not allowed. These are:
1. Portlet aren’t allowed to set the character set encoding of the response.
2. Portlet also aren’t allowed to set the HTTP headers on the response.
3. Portlet cannot manipulate the URL of the client request to the portal.

Enjoy :)

Download JSR 286 portlet specification 2.0

Thursday, May 21, 2009

New features in JSR 286 portlets

The main features are added in the jsr 286 specification are:
1. Events – enabling a portlet to send and receive events and perform state changesor send further events as a result of processing an event.
2. Public render parameters – allowing portlets to share parameters with other portlets.
3. Resource serving – provides the ability for a portlet to serve a resource.
4. Portlet filter – allowing on-the-fly transformations of information in both the request to and the response from a portlet.

Click here to download the complete jsr 286 specification.