There are so many things which are very clear and understood but if someone ask, it become difficult to explain them in deep. The topic I am going to write today, is something like that. Hope, you'll enjoy reading it, as I am going to write this time full on text, no practical implementation.
The contents of servlets provide generally takes up the whole page in a browser (if you are not framing them), and portlets content are wrapped in a window and we can place multiple portlets on same page with one another and each can provide different content and functionality. A portlet behaves like a full fledged application. The portal can provide some house keeping functionality and secured single point of entries to all of the portlets on a page.
lets see first some differences among portlets and servlets
The contents of servlets provide generally takes up the whole page in a browser (if you are not framing them), and portlets content are wrapped in a window and we can place multiple portlets on same page with one another and each can provide different content and functionality. A portlet behaves like a full fledged application. The portal can provide some house keeping functionality and secured single point of entries to all of the portlets on a page.
lets see first some differences among portlets and servlets
- Servlets can provide complete web pages, whereas portlets only provide fragments. These fragments are then aggregated to form a complete web page by the portal.
- Portlets aren't allowed to generated HTML code that contains tags such as base, body, frame, frameset, head, html, or title. The iframe tag can be used with caution.
- 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 one page.
- Communication between the web client and the portlets is performed through the portal.
- Portlets can be provided with buttons or controls to manipulate the portlet's window states or portlet modes.
- Multiple instances of a single portlet can be placed onto the same page.
- Portlets support persistent configuration and customization.
- Portlets also support user profile information.
- Portlets support two scopes within the session; application scope and portlet scope .
- Servlets and portlets are web based components that utilize Java for their implementation.
- Portlets are managed by a portlet container similar to a servlet container.
- Both of these components generate content, which can be static or dynamic.
- Both portlets and servlets have a lifecycle that is controlled by the container.
- The client/server model is used for both servlets and portlets.
- The packaging and deployment are essentially the same.
- The manner in which the classes are loaded and the class loaders that perform the work are also the same.
- Lifecycle management is similar.
- The Request and Response semantics are also similar.
- Portlet aren't allowed to set the character set encoding of the response.
- Portlet also aren't allowed to set the HTTP headers on the response.
- Portlet cannot manipulate the URL of the client request to the portal.
- Portlet Modes : Each portlet has a current mode, which indicates the function the portlet is performing.
- All JSR 168 compliant portals should support the View, Edit and Help modes.
- Window States :Window states indicate the amount of portal page space that will be assigned to a portlet.
- Portlet Preferences :Portlets can be configured to provide a custom view or behavior for different users.