Skip to main content

Developing portlets that use JavaBeans and JSP components

Make it easy with the Portal Toolkit Plugin for WebSphere Studio Application Developer V4.0.3

Balu Ramachandran (balur@us.ibm.com), Senior Software Engineer, IBM, Software Group
Balu Ramachandran
Balu is a Senior Software Engineer and an e-business architect for IBM Developer Relations Technical Consulting in Austin, Texas. He provides education, enablement, and consulting to ISVs. He is a certified Java Programmer, certified WebSphere Specialist, and a certified e-business technologist. You can contact him at balur@us.ibm.com.

Summary:  This article shows how WebSphere Studio Application Developer V4.0.3 is a premier J2EE development tool for developing portlets. It briefly discusses portals, WebSphere Portal Server V4.1.2, portlets, and the Portal ToolKit Plugin V4.x. The author includes step-by-step instructions for writing portlets using the Portal Toolkit Plugin. The sample portal application in this article is a portlet that calls a JavaBeans component to gather customer-specific information that's stored in a Java properties file. The portlet will use the JavaBeans information and send the result back to the requester using JavaServer Pages (JSP) pages. The JSP page will be embedded in the portlet when it is displayed to the user.

Date:  01 Oct 2002
Level:  Intermediate
Activity:  670 views

Introduction

A portal is a Web site that gives users a single point of access to Web-based resources by aggregating those resources in one place. Users can then log in only to the portal itself instead of logging in separately to each application that they intend to use.

WebSphere Portal Server V4.1

IBM WebSphere Portal is part of the WebSphere software platform, which fundamentally does three things:

  • Provides access to information across a spectrum of users, devices, and customization options.
  • Integrates and automates business processes.
  • Builds, connects, and manages applications.

WebSphere Portal Server is a highly scalable portal server that implements a strategic open-source portal framework. Portal Server V4.1 builds on the core services of WebSphere Portal Family V2.1. Portal Server provides:

  • Access to a wide variety of portal and business services, such as WebSphere Commerce Suite for eCommerce, EIP for information categorization, and Lotus tools for advanced collaboration and personal information management (PIM) such as Calendar, Mail, and Sametime.
  • Connectivity to legacy systems through workflow, EAI, and so on.

WebSphere Portal also provides other services such as the following:

  • Single sign-on
  • Security
  • Web content publishing
  • Search
  • Personalization
  • Collaboration services
  • Enterprise application integration
  • Support for mobile devices
  • Site analytics

Portlets

Portlets are central to IBM WebSphere Portal. As special reusable Java servlets that appear as defined regions on portal pages, portlets provide access to many different applications, services, and Web content. WebSphere Portal ships a rich set of standard portlets, including portlets for displaying syndicated content, transforming XML, and accessing search engines and Web pages. Several third-party portlets are also available, such as Enterprise Resource Planning (ERP) and Customer Relationship Management (CRM). Portal Server also provides an API that you can use to create custom portlets. By aggregating portlets in one place and giving users the power to customize their own desktops, Portal Server gives business partners, customers, or employees a means for doing business efficiently and with high satisfaction.

WebSphere Studio Application Developer V4.0.3

Over time, the WebSphere Studio product suite replaces the existing Java and Web application development tools (VisualAge for Java and WebSphere Studio - classic). The new tools are built on an open platform and have leading-edge Enterprise JavaBeans (EJB) and J2EE tooling based on J2EE 1.2 specifications. They also have the following:

  • Enterprise connectivity
  • Built-in unit test environment (WebSphere Application Server and Tomcat)
  • Incremental compilation
  • Rich debugging (including remote debugging)
  • Integrated team environment

The WebSphere Studio Development Environment is built on the highly-pluggable WebSphere Studio Workbench open-source platform. On top of this platform, IBM implemented the WebSphere Studio Application Developer, and other vendors are encouraged to integrate their tools onto the platform. The development environment is tailored for role-based development, with appropriate user interface functions for specific roles in the development process. All assets are stored in a file-based repository. Over time, all functions of VisualAge for Java and WebSphere Studio-classic will be implemented in Application Developer. Web services are already supported in the new tool.

Portal Toolkit Plugin

The Portal Toolkit is for developing portlet applications and is a plug-in to Application Developer V4.0.3. Portal Toolkit provides:

  • Portlet projects in which you can create abstract portlets, JSP portlets, servlet invoker portlets, XML/XSL portlets, and multi-device/view portlets.
  • Portal Server projects in which you can publish your portlet application onto your target Portal Server machine. Your portlet will appear on the debug page of your Portal Server.
  • Portlet application samples for enterprise applications.

Developing and deploying a JSP session portlet

As an example, I'll show you how you can develop a portlet that uses a JavaBeans component called PortalBean to retrieve stored values from a properties file. The portlet instantiates a stored JavaBeans class and stores this JavaBeans instance in the request attribute of the portlet session. Thereafter the portlet calls a JSP component and passes along the values of the request and response attributes. The JSP component will then use the passed JavaBeans class and output the appropriate values in the portlet.

Installing Portal Toolkit Plugin for Application Developer

  1. If you don't already have the Portal Toolkit Plugin, download it from Portal Toolkit Plugin.
  2. Follow the instructions to install the plugin into Application Developer V4.0.3. Note the prerequisites.
  3. Add the WebSphere Application Server JVM to the list of available JVM's for Application Developer:
    • Open Windows-Preferences. Select Java - Installed JRE.
    • Click Add New.
    • Browse and choose X:\WebSphere\AppServer\java.
    • Once it shows up under the installed JRE list, check the box next to WAS JRE to make it the default JRE.
    • Click OK to save the changes.

Developing the MyJSPPortal Portlet

				FirstName=Joe	
				LastName=Generic
				Email=com

		package portal;

		/**
		 * Insert the type's description here.
		 * Creation date: (1/12/2002 6:34:35 PM)
		 * @author: Administrator
		 */
		public class PortalBean {
		/**
		 * PortalBean constructor comment.
		 */

		 public String fName;
		 public String lName;
		 public String eMail; 

		public PortalBean() {
			super();
		}
				
		/**
		 * Insert the method's description here.
		 * Creation date: (1/14/2002 10:28:20 PM)
		 * @return java.lang.String
		 */
		public String eMail() {
			return null;
		}
				
		/**
		 * Insert the method's description here.
		 * Creation date: (1/14/2002 10:28:20 PM)
		 * @return java.lang.String
		 */		
		public String getEMail() {
			return eMail;
		}
				
		public String getfName()
		{
			return fName;
		}

		/**
		 * Insert the method's description here.
		 * Creation date: (1/14/2002 10:35:04 PM)
		 * @return java.lang.String
		 */
		public String getlName() {
			return lName;
		}
				
		/**
		 * Insert the method's description here.
		 * Creation date: (1/14/2002 10:29:41 PM)
		 * @param email java.lang.String
		 */
		public void setEMail(String email) {
			eMail = email;
		}
				
		public void setfName(String myName)
		{
			fName = myName;
		}
				
		public void setlName(String myName)
		{
			lName = myName;
		}
	}

Deploying the MyJSPPortal Portlet

To deploy the MyJSPPortal portlet, follow these steps:

  1. Log on to the portal as a portal administrator:
    • Open Internet Explorer and enter the following address: http://portal.ibm.com/wps/portal (or the appropriate URL).
    • Click the key icon at the top-right corner to log in.
    • Use the User ID/Password wpsadmin/wpsadmin to log in as Administrator.
  2. Access the Portlet Administration Portlet:
    • Click on the drop down menu at the top left corner that has an entry for Home page currently displayed and select Portal Administration.
  3. Click Browse to locate the MyJSPPortal.war file (C:\temp\MyJSPPortal.war) that you exported in the previous section and click Next.
  4. Click Install to install the portlet. You should see a message indicating that the portlets were successfully installed.
  5. Add the MyJSPPortal portlet to the Home - Welcome page:
    • Click on the drop-down menu at the top left corner of the screen with the entry Portal Administration.
    • Choose Work with Pages.
    • Click on the Page Group drop-down menu and select Home.
    • Click on the Page drop-down menu and select Welcome.
    • Click Get Portlets at the top of the screen
    • Choose Show all portlets and click Go.
      • You will now see a list of portlets that are deployed. Scroll down and locate the MyJSPPortal portlet. Click on the + symbol at the leftmost column in the row, which will select the MyJSPPortal portlet for deployment.
    • Scroll up the page and click OK at the top left side of the header.
    • Once you are back to the original page, locate and highlight the MyPortal portlet. Click the + symbol to add the MyPortal portlet to the Welcome page.
    • Finally, click the Activate icon at the bottom-left of the screen to activate the Welcome portal page with the added MyPortal portlet.
  6. View the Home page to see your changes:
    • Locate and click the drop-down menu at the top left corner and select to view the Home page.

Resources

About the author

Balu Ramachandran

Balu is a Senior Software Engineer and an e-business architect for IBM Developer Relations Technical Consulting in Austin, Texas. He provides education, enablement, and consulting to ISVs. He is a certified Java Programmer, certified WebSphere Specialist, and a certified e-business technologist. You can contact him at balur@us.ibm.com.

Comments (Undergoing maintenance)



Trademarks  |  My developerWorks terms and conditions

Help: Update or add to My dW interests

What's this?

This little timesaver lets you update your My developerWorks profile with just one click! The general subject of this content (AIX and UNIX, Information Management, Lotus, Rational, Tivoli, WebSphere, Java, Linux, Open source, SOA and Web services, Web development, or XML) will be added to the interests section of your profile, if it's not there already. You only need to be logged in to My developerWorks.

And what's the point of adding your interests to your profile? That's how you find other users with the same interests as yours, and see what they're reading and contributing to the community. Your interests also help us recommend relevant developerWorks content to you.

View your My developerWorks profile

Return from help

Help: Remove from My dW interests

What's this?

Removing this interest does not alter your profile, but rather removes this piece of content from a list of all content for which you've indicated interest. In a future enhancement to My developerWorks, you'll be able to see a record of that content.

View your My developerWorks profile

Return from help

static.content.url=http://www.ibm.com/developerworks/js/artrating/
SITE_ID=1
Zone=Sample IT projects
ArticleID=10223
ArticleTitle=Developing portlets that use JavaBeans and JSP components
publish-date=10012002
author1-email=balur@us.ibm.com
author1-email-cc=

My developerWorks community

Tags

Help
Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere).

My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).

Use the search field to find all types of content in My developerWorks with that tag. Popular tags shows the top tags for this particular content zone (for example, Java technology, Linux, WebSphere). My tags shows your tags for this particular content zone (for example, Java technology, Linux, WebSphere).