# How Do I: Create a Portlet?

Portlets are the view components used to expose many types of resources in a Portal Web application. As such, a new portlet can be associated with an existing resource, or created first and associated with a resource later:

- Create the Resource First
- Create the Portlet First

## Create the Resource First

1. Create or open a portal's *.portal file in the IDE. You can then drag a resource, such as a JSP, into one of the portal's placeholder areas. WebLogic Workshop prompts you:

2. If you click Yes, the Portlet Wizard appears and creates a portlet using that resource as the content.

> In addition to JSP pages, you can drag personalization resources such as content selectors and other placeholders onto a portal's placeholder.

## Create the Portlet First

1. Alternatively, right-click on a folder in your Portal Web Project and select New > Portlet.

2. Name the portlet and click Create.

3. The Portlet Wizard is invoked and displays its Select Portlet Type screen. You have several options:

   The following table describes the portlet type options:

   Type | Description
   JSP/HTML Portlet | Creates a portlet that points to a JSP or HTML file for its content. These types of portlets can be simple to implement and deploy, and provide basic functionality without a lot of complexity. However, business logic and presentation layer can get combined in the JSPs; as the application grows, this often leads to escalating maintenance costs while trying to update the webapp and share code. This type of portlet is not well suited for advanced portlet navigation.
   Java Portlet | Creates a JSR 168 compliant portlet. This creates a Java file. Accommodates portability for portlets across platforms. Does not require the use of portal server specific JSP tags. The behavior is similar to a Servlet (although there are differences). For related information, see "Developing JSR 168 Portlets with WebLogic Portal 8.1" on the BEA dev2dev site. This type of portlet is intended for software companies and other enterprises that are concerned with portability across multiple portlet containers. Current disadvantages are that this type of portlet does not leverage BEA advanced portlet features, and this type requires a deeper understanding of the J2EE programming model.
   Java Page Flow Portlet | Creates a portlet that uses Java Page Flows to retrieve its content. Allow you to separate the user interface code from navigation control and other business logic. Provides the ability to model both simple and advanced portlet navigation. Allow you to leverage other resources such as Java Controls and Web Services. Provides a visual IDE environment to build rich applications based on Struts. The advanced page flow features are not necessary for static or simple, one-view portlets.
   Struts Portlet | Creates a Struts-based portlet.
   Remote Portlet | Creates a WSRP-compliant remote portlet. Remote, or "proxy," portlets consume content, including applications, from WSRP-compliant producers. This allows you to populate a portlet from an external source rather than creating that content yourself.

Related Topics

Portlet Basics

Pageflow and JSP Reference