WebSphere Portal 7 and Spring 3.0 Portlet MVC Integration :


WebSphere Portal 7 and Spring 3.0 Portlet MVC Integration :

By Sal Pece


WebSphere Portal 7 and Spring 3.0 Portlet MVC Integration : Part 1

Other Articles by WebSphere Portal Expert Sal Pece:
Evaluating WebSphere Portal Server 7
Speeding Up Your WebSphere Portal Server 6.1 and 7 Installations

What happens when the industry leading Portal and the world's greatest application framework combine? Only good things!In this introductory article, I'll guide you through setting up the Spring 3.0 Portlet MVC Framework to work with JSR 286 Portlets running on WebSphere Portal 7. In particular, I'll show you how to:

  •      Download all the Spring and required libraries
  •      Deploy the example to WebSphere Portal 7
  •      Describe all the moving pieces and their purpose

[Author's Note: I'm making a few assumptions in this article. 1) You are familiar enough with WebSphere Portal 7 to create new pages and deploy portlets to a page. 2) You've done some research into Spring and Spring MVC and understand the benefits. 3) You understand the Portlet lifecycle and are ready to break the rules. ]

Where do we begin?

The best way to begin is with a working example. If offer the following options:

  1. SpringMVCPortlet2Project-selfcontained.war [LINK] Approximately 3MB - Contains the example code and all the requisite Spring and dependent JAR libraries
  2. SpringMVCPortlet2Project .war [LINK] Approximately 6 KB - Contains the example code only

The first option is the simplest to deploy. You can just download and install the Portlet Application as is and the example will work.

I would recommend the second option if you're planning to use Spring throughout your enterprise solution. You're better off learning how to locate and include the requisite libraries.

[Author's Note: If you selected the first option, skip the 'How do I obtain and configure the Spring and Requisite libraries for WebSphere Portal?' section, otherwise, continue.]

How do I obtain and configure the Spring and required libraries for WebSphere Portal?

The majority of Spring MVC examples online have developers load all the requisite Spring and Dependent Java libraries into the Web Project. I'm not a fan of this option. Instead I've decided to install the libraries to the shared Portal library.

Spring Libraries

  1. Download the Spring 3 libraries from the following site:
  2. Extract the following files from the dist folderorg.springframework.asm-3.0.5.RELEASE.jar

  3. Copy all those JARs to the following WebSphere Portal shared directory:


Dependent Library : Commons Logging

  1. Download the commons-logging library from the following site:
  2. Extract the commons-logging-1.1.1.jar file to the following directory:

Depending Library : Java Standard Tag Library

  1. Download the jstl-1.2_1 library from the following location:
    http://repo1.maven.org/maven2/org/apache/geronimo/bundles/jstl/1.2_1/ jstl-1.2_1.jar
  2. Copy the JAR to the following directory:

How do I install the example on WebSphere Portal 7?

The following steps describe how to install the Spring 3 Portlet MVC application. If you already know how to deploy portlets, feel free to skip this section.

  1. Start WebSphere Portal
  2. Open a browser and enter the following URL:


  3. Log in as a portal administrator v
  4. Click the Administration tab
  5. Select Portlet Management -> Web Modules
  6. Click the Install button
  7. Select the SpringMVCPortlet2Project.war file and click Next
  8. Click Finish
  9. Create a new page named Success, and deploy the Spring MVC Portlet 2.0 Example to the page.
  10. Navigate to the page

What does the example do?

I've kept things as simple as possible, so the example doesn't do much. Once it's deployed and running, you should see a page similar to the following example:

What's happening behind the scenes?

The request lifecycle for the Portal request


1) The client invokes the page request

2) WebSphere Portlet Engine invokes the Dispatcher Portlet

3) The Dispatcher Portlet dispatches requests to the ActionRequest and RenderRequest handlers

4) The RenderRequest handler returns the Model and View

5) The Dispatcher Portlet resolves the and renders the view

6) WebSphere Portal aggregates the Portlet content and returns the response to the client

What are the components of the Spring 3.0 Portlet MVC?

I've kept this example as simple as possible. The elements can be broken in to the following components:



[Author's Note: I made sure to include the source code in the WARs provided. The examples were built using Eclipse, rather than Rational Application Developer.]


Portlet Controller  
SpringMVCPortletController.java [LINK] The SpringMVCPortletController provides the handling logic for the ActionRequest and RenderRequest handler functionality.
Resource bundle  
springmvcportlet2portlet.properties [LINK] Resource bundle that defines the following:
  • Portlet title
  • Short name
  • Short name
SpringMVCPortletView.jsp [LINK] The View renders the results of the model.
Spring configuration  
SpringMVCPortlet-portlet.xml [LINK] Defines the following:
  • Portlet
  • Portlet Controller and handler mappings
  • View Resolver
applicationContext.xml [LINK] Defines the beans to invoke for the Spring Portlet MVC

Portlet Configuration

web.xml [LINK] Defines and instance of the ViewRendererServlet to allow the DispatcherPortlet to function
portlet.xml [LINK] Defines the following:
  • Portlet name
  • Supported modes
  • Resource bundle
  • DispatcherPortlet class
Note: Instead of defining a unique Portlet class, the DispatcherPortlet class is defined

What's next?

Now that we have a working example, we can start exploring more advanced features of Spring and Portlet integration. The next elements I'd like to explorer are Portlet filter alternatives, AJAX processing, and event handling. If you have any questions, please feel free to contact at salpece [aht] yahoo [dot] ca



Sal Pece is a Senior Systems Analyst and Instructor who refuses to specialize. Instead focuses his efforts as architect, administrator and developer on WebSphere Application Server, WebSphere Portal, and Lotus Connections 2.5 platforms. When he's not delivering custom solutions, or studying new technologies, he's serving up sumptuous feasts for his family and friends. His signature dish is a three cheese and mushroom stuffed chicken breast, wrapped in bacon, and smothered with a Raspberry Mustard cream sauce which he's named 'The Shona'.

Other Articles by WebSphere Portal Expert Sal Pece:

Evaluating WebSphere Portal Server 7
Speeding Up Your WebSphere Portal Server 6.1 and 7 Installations

13 Jan 2011