Wednesday, 9 October 2013

Difference and similarities between Servlet and Portlets



Difference and similarities between Servlet and Portlets


1.      Servlets provide content that normally takes up the whole page in a browser (unless you're using frames), and portlets provide content that is wrapped by a window.
2.      With portlets, you can have multiple portlets side by side with one another and each one can provide content and functionality that is different from the other.
3.      While Servlet always responds to single type of action - request, portlet (due to nature of its life cycle and stronger container bindings) has to respond to two types of actions: render request and Action Request
4.      Servlets can render complete web pages, whereas portlets renders html fragments. These fragments are aggregated by the portal into a complete web page.
5.      Portlets are not allowed to generate HTML code that contains tags such as body, frame, frameset, head, html, or title.
6.      A Portlet unlike a servlet doesn’t have URL attached to it so it cannot be accessed directly. Access is only through the portal page which holds the portlet.
7.      Portlets can be provided with controls to manipulate its window states or portlet modes.
8.      Multiple instances of a single portlet can be placed onto the same page.
9.      Portlets support persistent configuration and customization, profile information.
10.  Portlets have two scopes within session; application scope for communication across portlets and portlet scope for intra portlet communication.
11.  Portlet cannot set the character set encoding of the response nor can it set the HTTP response headers.
12.  Typical methods of Portlet API are doView(), doEdit(), doHelp() and processAction() while those of servlet are doService(), doPost(), doGet().






Similarities
1.      Servlets and Portlets are web based components which use Java for their implementation.
2.      Portlets are managed by a portlet container just like servlet is managed by servlet container.
3.      Both static and dynamic content can be generated by Portlets and Servlets.
4.      The life cycle of portlets and servlets 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, WAR/EARs.
7.      The manner in which the classes are loaded and the class loaders that perform the work are also the same.

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.

No comments:

Post a Comment

Very Impotent Links for Java and Portal development development

Jar Download for Spring  Maven Or Gradel Dependency for Spring