Monday, 22 April 2013

Servlets Vs Portlets


    Servlets and Portlets are web based components which use Java for their implementation.

    Portlets are managed by a portlet container just like servlet is managed by servlet container.

    Both static and dynamic content can be generated by Portlets and Servlets.

    The life cycle of portlets and servlets is controlled by the container

    The client/server model is used for both servlets and portlets

    The packaging and deployment are essentially the same, WAR/EARs.


    Servlets can render complete web pages, whereas portlets renders html fragments. These fragments are aggregated by the portal into a complete web page.

    The content type of JSR 168 portlets can be only cHTML, XHTML, WML. It does not support other content types.

    Portlets are not allowed to generate HTML code that contains tags such as body, frame, frameset, head, html, or title.

    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.

    Portlets can be provided with controls to manipulate its window states or portlet modes.

    Multiple instances of a single portlet can be placed onto the same page.

    Portlets support persistent configuration and customization, profile information.

    Portlets can have two types of request viz. render request and action request.

    Portlets have two scopes within session; application scope for communication across portlets and portlet scope for intra portlet communication.

    Portlet cannot set the character set encoding of the response nor can it set the HTTP response headers.

    Portlets doesn’t have access to request URL. So it cannot access the query parameters appended to the URL.
    Portlets cannot set cookies.

    Typical methods of Portlet API are doView(), doEdit(), doHelp() and processAction() while those of servlet are doService(), doPost(), doGet().
Post a Comment