Basically, Portlets are pluggable UI programming segments that are overseen and shown in a web portal. Portlets deliver pieces of markup code that are amassed into a portal. On the off chance that you have just worked with Servlets, at that point you ought to know that there are numerous similitudes among them and Portlets.
Like servlets, portlets are web segments that are deployed inside of a container and create dynamic content as per needs. In terms of the technical, a Portlet is a class that executes the javax.portlet. Portlet interface is bundled and deployed as a WAR document within a Portlet container (Portal Server).
Similarities between Servlets and Portlets
Doing the change to portlet development is easier than you might suspect. That is extensive in light of the fact that the authors of the underlying detail (JSR-168) utilized the Servlet determination as of the based on their documentation.
Therefore portlets work comparatively to servlets aside from with extra adjustments to represent the adjustment in technology.
Here are a couple of things you should know when getting ready to do the change to portlet development:
First of all, Both servlets and portlets utilize the “web.xml” deployment descriptor. However, portlets likewise have an extra deployment descriptor, portlet.xml, which must announce the majority of the portlets that will be utilized by the portlet container.
Rather than HttpServletRequest and HttpServletResponse objects, portlets expect either an ActionRequest or RenderRequest object and ActionResponse or RenderResponse objects.There are constraints in the items that portlets oversee, for example, not having direct access to the original servlet request for parameters (JSR 168). Yet, check your portlet determination and portlet container execution to confirm which highlights might possibly be accessible.
Portlets have a Context interface that enables designers to get to the Portlet application under which a portlet is running. This is like the servlet’s context interface.
Portlets have their own config object, PortletConfig, which can be utilized to get to properties inside the portlet.xml.
Portlets utilize the idea of portlet modes that enables designers to give changing levels of end-client control for survey, altering, or getting to help.
Dissimilarity between Portlets and servlets
- Portlets just produce markup fragments, not whole documents.
- Portlets are not specifically URL addressable. You can’t send someone URL of a portlet. But you can send him the URL of the page containing a portlet.
- Portlets can’t create subjective substance, since the substance produced by a portlet will be a piece of portal page. On the off chance that an entry server is requesting html/text, at that point all portlets ought to produce html/text content. Then again, if the portal server is requesting WML, at that point each portlet ought to produce WML content.