Leveraging 3270 or 5250 data within Web-based mashup applications

A guide to creating a 3270 feed with HATS and using the feed in IBM Mashup Center

Learn how to extract 3270 or 5250 data using IBM® Rational® Host Access Transformation Services, which can then be formed into an Atom data feed. This data feed can be utilized by IBM Mashup Center to consolidate with other data sources to create a new situational application for business users. We present an example of extracting data from a 3270 financial application, creating an Atom feed, cataloging that feed, and using that data to create an information dashboard for a loan officer.


John Feller, Manager, Emerging Technologies Toolkit Development, IBM

John Feller is the manager of the IBM Emerging Technologies Toolkit Development team. He manages a creative and energetic team of developers that architect, design, and develop innovative solutions that are then made available on alphaWorks. He is currently investigating best practices to build online communities using Web 2.0 technologies like wikis, blogs, tagging, and Ajax user interfaces. He earned a bachelor's degree in computer science at the University of Dayton and a master's degree in computer and information science at Ohio State University. He received an MBA from the University of North Carolina, Chapel Hill, and is certified as a Project Manager Professional with the Project Management Institute.

Chris Gladd, Pre-Professional Programmer Intern, IBM

Chris Gladd is a student at Pennsylvania State University majoring in Computer Science. Currently, he is a co-op on the IBM jStart Emerging Technologies team and has over three years of software development experience.

29 June 2009 (First published 09 June 2009)

Also available in Chinese Japanese Spanish

Editor's note: Know a lot about this topic? Want to share your expertise? Participate in the IBM Lotus software wiki program today.


A lot of enterprise information exists in mainframe applications that are currently accessed using 3270 or 5250 consoles. If this mainframe data could be available in a format that allows it to be easily combined with other data, either within the enterprise or available on the Internet, business users could have the ability to harness this data to help solve business issues using a feature-rich, modern browser interface. In this article, we describe a use case in which valuable financial information is "locked up" in a 3270 data application and a loan officer wants to extract that data to create a new Web-based mashup application. A mashup is a lightweight Web application created by combining information or capabilities from more than one existing source to deliver new functions and insights. The useful parts of green-screen (3270) applications can be isolated, wrapped, and then used in a mashup framework to provide new insights to the business user.

First, the content in mainframes must be formatted as data feeds before it can be consumed by a mashup framework. This article provides a step-by-step guide to generating Atom feeds for mainframe content using Rational® Host Access Transformation Services (HATS). The developerWorks® article, "Use HATS to generate Atom feeds for mainframe applications," written by Ramakrishnan Kannan, Prasad Nagaraj, and Saikrishna Vaidyanathan, presents how to create Atom feeds from 3270 data. This article extends their concept by providing another example and by creating a situational Web application using IBM Mashup Center.

Overview of the scenario

A financial services loan officer for a bank has data that she needs to access to determine if a current bank account holder can obtain a new car loan. In a green-screen 3270 mainframe application, the loan officer is able to find out current account balances for account holders. She then has to use a Web application to obtain the account holder’s credit score. Another application allows her to determine the number of car theft reports in the geographic area of the loan applicant. Currently, the loan analyst has to switch to three different computer applications to access information that she needs to determine if the account holder is eligible for a new car loan. This article primarily focuses on extracting data from the 3270 application. The credit score and car theft reports for a geographic area are assumed to have been already turned into data feeds by IBM Mashup Center feed generator or are already accessible using a Web browser.

Account balance information is currently accessed through a 3270 application as shown in figure 1.

Figure 1. 3270 application data
3270 application data

Using IBM Rational Host Access Transformation Services (HATS), you can create an Atom data feed. This data feed is then combined with other data to create a composite dashboard application, shown in figure 2, for the loan officer.

Figure 2. Composite dashboard application
Composite dashboard application

HATS Atom feed walkthrough

Here are a step-by-step guide and code template examples that you can use to extract 3270 application data and place it in a mashup application.

Create a new HATS project

Create a new Rational Host Access Transformation Services (HATS) project with default settings. Follow these steps:

  1. Enter the host name in the Connections Settings window. All other fields are filled in by default; modify if necessary. Click Finish. Figure 3 shows one set of connection settings; your settings might be different.

    Figure 3. HATS Create a Connection window
    HATS Create a Connection window

Record a macro

Record a macro to query for information by doing the following:

  1. Right-click your main connection, and click Open HATS Host Terminal and then main.

    You should see the 3270 screen shown in figure 4.

    Figure 4. 3270 Logon screen within HATS host terminal environment
    3270 Logon screen within HATS host terminal environment
  2. Click the Record button at the top of the screen, and give your macro a name.
  3. Step through the process that you want to use, and select the lines that you want to extract on each page by clicking the Add Extract Action button. See figure 5.

    Figure 5. Selection area to extract 3270 data
    Selection area to extract 3270 data
  4. Select the Extraction Format option Extract this region as a list of strings for each extract action so that each line is a different entry in a list later. All other values are set by default. Click Finish.

    Figure 6. Edit Extract window
    Edit Extract window

Create an Integration Object

Create an Integration Object from the macro by following these steps:

  1. Right-click your macro and select the Create Integration Object option.
  2. Open the new Java™ source under Integration Object; it has the same name as the macro. (See the sample code in listing A-1 in the appendix of this article.)
  3. Note the defined HAOVariables near the top. Change the last argument in each of their instantiations from HAO_VARIABLE_SIMPLE to HAO_VARIABLE_ARRAY. This change allows you to get the array of extracted lines instead of a single string that combines the lines. Change the arguments as follows:

    • From:
      HAOVariable inquiry1 =
      new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_SIMPLE);
    • To:
      HAOVariable inquiry1 =
      new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
  4. Now add a Getter of type vector for each inquiry that returns your_inquiry.oMultiValues. For example, see the code in listing 1.
Listing 1. Example of Getter for the inquiry result array
public Vector getInquiry1AsVector()
  hPubErrorOccurred = 0;
  if (HPubTracingOn) { Ras.trace( className, "getInquiry1 array: ", 
  inquiry1.stringValue); }
  return (inquiry1.oMultiValues); 

Create Model 1 Web pages

Next, create Model 1 Web pages from your Integration Object by right-clicking your integration object and selecting the Create Model 1 Web Pages option. See figure 7.

Figure 7. Create Model 1 Web Pages window
Create Model 1 Web Pages panel

Use the default settings that are given and click Finish to create a JSP page under Model 1 Pages.

Alter the JSP page

Next, alter the JSP page to output the Atom feed. Follow these steps:

  1. You now have a JSP page under Web Content - Model 1 Pages; double-click it to go to the source.
  2. Using the provided JSP file, InquiryMacroOutput.jsp (shown in listing A-2 in the appendix of this article) as a guide, replace the JSP code with your own that outputs an Atom feed. Disregard the warnings about parameterizing the ArrayList because JSP does not handle parameterization.

Test the JSP page

Test the JSP page by going to its endpoint and looking at the Atom feed.

If you use the Microsoft® Internet Explorer browser, your page should like the text in figure 8.

Figure 8. Resulting Atom feed from the JSP page
Resulting Atom feed from the JSP page

Add the new Atom feed

To add the new Atom feed to IBM InfoSphere™ MashupHub, follow these steps:

  1. Open InfoSphere MashupHub and click the New Feed under the Create section of the MashupHub Homepage.
  2. Select Existing RSS or Atom Feed (Registration) under departmental in the list that displays as shown in figure 9. Click Next.

    Figure 9. New feed creation panel within IBM Mashup Center
    New feed creation panel within IBM Mashup Center
  3. Enter the URL of the JSP page that you created, and then click Next. See figure 10.

    Figure 10. Specify Atom feed URL within MashupHub feed creation window
    Specify Atom feed URL within MashupHub feed creation window
  4. Give the new feed a Title and Description and any tags that you want associated with the feed, and then click Finish.
  5. The feed has now been saved in the InfoSphere MashupHub Catalog. You can add it to IBM Lotus Mashups by selecting the Add to Lotus Mashups option.
  6. Enter the location of your Lotus Mashups server, and then click Next.
  7. Optionally, change the Title, Description, Category or Feed Viewer options, and then click Finish.

Build a mashup in Lotus Mashups using your feed

Follow these steps to build a mashup in Lotus Mashups using your feed:

  1. Open Lotus Mashups and optionally open a new page for your mashup.
  2. Click the Go to Edit button to begin building your mashup.
  3. Select your feed from the toolbar; by default displays in the Collaboration option in the toolbar as shown in figure 11. Drag the feed onto the page. Resize it if necessary.

    Figure 11. Data viewer widget within Mashup Center showing Atom feed of 3270 data
    Data viewer widget within Mashup Center showing Atom feed of 3270 data
  4. Click the Favorites option on the toolbar, and add OpenStreetMap and any other widgets that you want to use in your mashup application. For our example, there are feeds that supply Credit Report History and Car Theft Reports for a given geographical area. The OpenStreetMap and Website Displayer widgets are used. Wire the elements from the 3270 data table to these new widgets to create a customized application to address your business needs.
  5. When an item is clicked in the feed you should see the corresponding car theft information on the map and the credit report information in the Website Displayer widget as shown in figure 12.

    Figure 12. Completed Loan officer dashboard mashup application
    Completed Loan officer dashboard mashup application


IBM Mashup Center and Rational Host Access Transformation Services can let you leverage data that is currently locked up in 3270 or 5250 applications and use the data for other Web-based applications. This article provides a step-by-step guide on how to extract 3270 data and create a new situational mashup application. Code templates are supplied that you can tailor to extract data from a variety of 3270 applications.

Appendix: Code Listings

Listing A-1. Code for the integration object (InquiryMacro.java)
import java.util.Vector;

import com.ibm.HostPublisher.IntegrationObject.*;
import com.ibm.HostPublisher.Server.Ras;

public class InquiryMacro extends HPubHODCommon
  public static float  getIOTemplateVersion()  
  { return 7.0F; }       // Template version - HATS 7.0
  public static String getIOTemplateType()     
  { return "-DEFAULT"; } // Template type - Host Default
  public static String getIOVersionInfo()      
  { return "(IBM)"; }    // Version info - IBM supplied
  public static String getIOTemplateRevision() 
  { return ":1.1"; }     // Template revision per version - internal value
  public String hPubIOVersion= getIOBaseVersion()+";"+getHPubBeanType()+
  public String getIOVersion() { return hPubIOVersion; }

  // Generated Objects altered to export their data as
  HAOVariable inquiry1 = 
  new HAOVariable("","inquiry1","inquiry1",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
  HAOVariable inquiry2 = 
  new HAOVariable("","inquiry2","inquiry2",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
  HAOVariable inquiry3 = 
  new HAOVariable("","inquiry3","inquiry3",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
  HAOVariable inquiry4 = 
  new HAOVariable("","inquiry4","inquiry4",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);
  HAOVariable inquiry5 = 
  new HAOVariable("","inquiry5","inquiry5",false,"",0,0,63,7,HAO_VARIABLE_ARRAY);

******** Automatically Generated Code Not Shown ********

  /* Added Getters to return the inquiries as a Vector */
  public Vector getInquiry1AsVector()
     return (inquiry1.oMultiValues);
  public Vector getInquiry2AsVector()
     return (inquiry2.oMultiValues);
  public Vector getInquiry3AsVector()
     return (inquiry3.oMultiValues);
  public Vector getInquiry4AsVector()
     return (inquiry4.oMultiValues);
  public Vector getInquiry5AsVector()
     return (inquiry5.oMultiValues);
Listing A-2. Code for JSP that creates the Atom feed (InquiryMacroOutput.jsp)
<%@ page contentType="text/html;charset=UTF-8"errorPage="../BasicIOErrorPage.jsp"%>
<%@ page import="com.ibm.hats.runtime.*,
<%@ taglib uri="hats.tld" prefix="HATS"%>

<% IOGV.process(request); %>

<jsp:useBean id="InquiryMacro" type="IntegrationObject.InquiryMacro"
	class="IntegrationObject.InquiryMacro" scope="request">
	<jsp:setProperty name="InquiryMacro" property="*" />

	//Use the Integration Object that is instantiated above
	//to get data from the 3270 machine.
	InquiryMacro.doHPTransaction(request, response);
	try {
		// Build the feed to return from the page here.
		// A well-formed Atom Feed should contain the
		// following: A root "feed" element with "title",
		// "updated", "author" (containing "name" and "email"), and "id"
		// Create new feed factory
		DocumentBuilderFactory feedFactory = DocumentBuilderFactory.newInstance();
		// Create a new feed builder from the feedFactory
		DocumentBuilder feedBuilder = feedFactory.newDocumentBuilder();
		// Create a new document from the feed builder
		Document doc = feedBuilder.newDocument();

		// Create the root "feed" Element for the Atom Feed
		Element root = doc.createElementNS(
		"http://www.w3.org/2005/Atom", "feed");
		// Create the "title" element for the Atom Feed
		Element title = doc.createElement("title");
		// Append the title to the root element
		// Create a text node for the title element
		Text titleText = doc.createTextNode("Sample Feed from HATS");
		// Append the text to the title node

		// Create the "updated" element for the root of the Atom Feed
		Element updated = doc.createElement("updated");
		Text updateText = doc.createTextNode(new Date().toString());
		// Create the "author" element for the root of the Atom Feed
		Element author = doc.createElement("author");
		// Created the "name" element for under the author element
		Element name = doc.createElement("name");
		// Create the "email" element for under the author element
		Element email = doc.createElement("email");
		name.setTextContent("IBM Hats");
		// Append the name and email to the author
		// Append the author element to the root
		// Create the "id" element for the root of the Atom Feed
		Element id = doc.createElement("id");
		// Add all of the inquiries to an array to loop through
		// and construct the body of the Atom Feed
		ArrayList inqueries = new ArrayList();
		// Create multiple "entry" elements from the inquiries
		// and add them to the root "feed"
		// A well-formed entry element should contain title,
		// link, id, updated, and content
		for (int i = 0; i < 5; i++) {
			// Get the vector of strings from the array JSP can't 
			// have parameterized types so it must be generic
			Vector inquiry = (Vector) inqueries.get(i);
			// Create the top element for the new Entry
			Element entry = doc.createElement("entry");
			// Append the entry to the root "feed" element
			//Create and append the title element to the Entry
			Element titleEntry = doc.createElement("title");
			titleEntry.setTextContent("Entry #" + i);
			//Create and append the link element to the Entry
			Element link = doc.createElement("link");
			link.setAttribute("href", "http://www.ibm.com");
			//Create and append the id element to the Entry
			id = doc.createElement("id");
			id.setTextContent("http://www.ibm.com/id" + i);
			//Create and append the updated element to the Entry
			Element updatedEntry = doc.createElement("updated");
			Text updateEntryText = doc.createTextNode(new Date()

			Element summaryEntry = doc.createElement("content");
			//******* If you plan on having html content here, you should set
			//******* the type attribute to html so it will display correctly
			//******* by uncommenting the following lines
			//summaryEntry.setAttribute("type", "html");
			//summaryEntry.setAttribute("mode", "escaped");
			// Create and append any data nodes from your inquiry to
			// the content node of the entry
			Element record = doc.createElement("Number");

			Element uname = doc.createElement("Name");

			Element address = doc.createElement("Address");

			Element phone = doc.createElement("Phone");

			Element date = doc.createElement("Date");

			Element amount = doc.createElement("Amount");

			Element comment = doc.createElement("Comment");
			// Append the content element to the entry element
		// The following block transforms the Feed into a consumable
		// string for the out.print
		TransformerFactory feedTransformerFactory = TransformerFactory.newInstance();
		Transformer feedTransformer = feedTransformerFactory.newTransformer();
		feedTransformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
		feedTransformer.setOutputProperty(OutputKeys.INDENT, "yes");
		StringWriter sw = new StringWriter();
		StreamResult result = new StreamResult(sw);
		DOMSource source = new DOMSource(doc);
		feedTransformer.transform(source, result);
		//Print out the constructed feed xml as the content of the page

	} catch (Exception e) {



  • Read the developerWorks article, “Use HATS to generate Atom feeds for mainframe applications,” written by Ramakrishnan Kannan, Prasad Nagaraj, and Saikrishna Vaidyanathan. This article presents a good foundation on how to create Atom feeds from 3270 data.
  • Learn more about Rational Host Access Transformation Services (HATS). With HATS, you can extend your 3270 and 5250 host applications to the Web, to a portlet, to a rich client, or to browsers on mobile devices quickly, easily, and with low risk. There is a trial version that you can download.
  • Take the tutorial, Creating a Web Service using HATS. This lab teaches you how to use HATS to create a Web service that exposes logic contained in a System i 5250 green screen application. This lab shows new features in V7.1, including the new Visual Macro Editor tooling.
  • Refer to the HATS Help Documentation. Read a complete overview of HATS.
  • Learn more about IBM Mashup Center. Find an easy to use business mashup solution, supporting line of business assembly of dynamic situational applications — with the management, security, and governance capabilities IT requires. A free trial download is available for developers.
  • Read the Mashup Center wiki, which contains articles on installing, administering, deploying, and using IBM Mashup Center, including tutorials for new users.
  • Watch the video that complements this article.

Get products and technologies

  • Download a trial version of IBM Mashup Center by using the online trial version located at the IBM Lotus Greenhouse Web site.



developerWorks: Sign in

Required fields are indicated with an asterisk (*).

Need an IBM ID?
Forgot your IBM ID?

Forgot your password?
Change your password

By clicking Submit, you agree to the developerWorks terms of use.


The first time you sign into developerWorks, a profile is created for you. Information in your profile (your name, country/region, and company name) is displayed to the public and will accompany any content you post, unless you opt to hide your company name. You may update your IBM account at any time.

All information submitted is secure.

Choose your display name

The first time you sign in to developerWorks, a profile is created for you, so you need to choose a display name. Your display name accompanies the content you post on developerWorks.

Please choose a display name between 3-31 characters. Your display name must be unique in the developerWorks community and should not be your email address for privacy reasons.

Required fields are indicated with an asterisk (*).

(Must be between 3 – 31 characters.)

By clicking Submit, you agree to the developerWorks terms of use.


All information submitted is secure.

Dig deeper into IBM collaboration and social software on developerWorks

Zone=Lotus, XML
ArticleTitle=Leveraging 3270 or 5250 data within Web-based mashup applications