Why buy into portlets?

What are portlets?

Imagine a page divided into two sections. In one section the user is displayed a list. There is no other functionality is in this section. This section consists of just one JSP. In another section the user sees a list and he can add to the list as well by adding a new entry to the list through a textfield. This section has two JSPs, one for displaying a list (say display.jsp) and another for entering a value in a textfield (say add.jsp). Each section is a portlet and the JSPs within act independently and can submit to a handler class independently as well. A portlet can contain one or more JSPs depending on what the user is doing in that portlet at the moment; looking at a list or adding a value to a list. Let us call the first portlet, portletA, and the second, portletB. The portlet container combines add.jsp and display.jsp to form portletB. Also the portlet container can combine portletA and portletB to form a page. Thus the page described above will basically contain 3 JSPs, one in the first portlet, and two in the second.

Where would one use portlets and what are its advantages?

Think of it from the perspective of a large company with a website where it offers numerous services. Here it makes sense for them to use a portal since they have lots of independent businesses – all of them occupy some space on a single page. For example, if you look at yahoo (http://my.yahoo.com), it has mail, calendar, news; everything on one page and if a user logs in he can customize the layout of the page. In this case, the user can customize the page by adding or removing portlets; but some portals can only be modified by the portal administrator. The portal framework pulls in all the portlets and the portal administrator can position and align the portlets. The benefit is that an administrator is able to change the look and feel of the app without having to go through a software development cycle.
So the idea is you divide a page into small standalone sections, the section being a portlet, each portlet being backed by some code/actions. A portal administrator can drag these widgets around and assemble in whatever fashion he wishes to create the complete portal page, something like how an html page is divided into frames.
Java follows some standard for portlet technology- JSR, followed by some number which is a portal standard. This combination is some portal standard from Sun that is supposed to bring uniformity in all portal vendors on how they implement their portal server (just like how all vendors support the java JDBC API). Most portal servers have some support for the standard but many have gone their own route so one portal doesn’t look like another.
To repeat, the advantage with portlets is that the administrator can decide to align the page differently, for instance if he likes to make one portlet smaller or replace it with an advertisement.
The Weblogic portal I think has a user interface where administrator can position and move around the portlets using drag, drop and resize etc using portlets.