20
Sat, Apr
5 New Articles

Building Dynamic Web Pages with Net.Data

Typography
  • Smaller Small Medium Big Bigger
  • Default Helvetica Segoe Georgia Times

The World Wide Web was designed as an information-sharing medium using static hypertext markup language (HTML) documents. The Common Gateway Interface (CGI) extended HTML to allow the dynamic construction of Web pages by server-resident programs. This article discusses how application developers are building solutions for the Internet today using CGI programming standards. Also discussed is IBM’s newly announced Net.Data product, which simplifies the task of writing CGI programs that access DB2 legacy databases and host-centric legacy applications.

The CGI Standard

The CGI standard allows Web developers to create applications that interact with Web end users. This standard describes how data from a fill-in HTML form is passed back to the HTTP Web server, where an invoked program processes the data. CGI programs follow a formal process to send response data back to Web users. Figure 1 shows the flow of data from a Web browser to an HTTP server to a CGI program and back. Because CGI programs format and send tailored HTML documents (because each user supplies new and unique information on the form), they are building what is referred to as dynamic Web pages.

The CGI program flow can be broken into three steps.
1. The user completes a form that may contain text boxes, check boxes, buttons, or other response devices.

2. When the user clicks on the submit button, data flows to the HTTP Web server (in our case, an AS/400).

3. The HTTP server places the form data into a standard area, either as environment variables or as standard input, and then invokes the CGI program. The CGI


program parses and processes the forms data and then builds a dynamic HTML document that is returned through the HTTP server to the user.

Because the CGI standard was developed on UNIX-based systems, the languages and methods used to implement CGI programs reflect their UNIX heritage. Prior to AS/400 Web server products such as IBM’s Internet Connection for AS/400, I/NET’s WebServer/400, and Advanced Business Link’s BusinessLink/Web, CGI programs were almost always written in languages such as C, Perl, and Tcl—languages that most AS/400 developers do not have expertise in. With the AS/400 products, CGI programs can be developed in RPG, COBOL, CL, and C.

IBM and other companies are taking the developments a step further. They are delivering prepackaged CGI programs called gateways that can be used without in- depth knowledge of CGI programming and standards. Examples of gateway programs include IBM’s 5250 HTML Gateway, I/NET’s Webulator, and OpenConnect’s OC://WebConnect—all prepackaged CGI programs that convert IBM 5250 green-screen data streams to HTML and vice versa, thus allowing Web browsers to run IBM 5250- based applications across the Internet. IBM also markets gateways for Information Management System (IMS), Customer Information Control System (CICS), and the MQ Series, delivering Web access to applications using these products.

This article focuses on Net.Data, an IBM gateway for interacting with data stored in DB2 databases (whether running on OS/400, OS/390, AIX, OS/2, Solaris, or HP/UX). Net.Data is a renamed and enhanced version of what used to be called DB2WWW. Net.Data is provided by IBM at no extra charge with all its Internet Connection products. On the AS/400, Net.Data is included in the no-charge program product 5763-TC1 (5617-TC1 for RISC boxes).

What exactly does Net.Data do, and how does one start using it? Let me give you a simple example that shows what a Net.Data application would look like to a Web user using Netscape Navigator. First, the Web user would see a form like the one shown in Figure 2. This Web application allows the user to request status information for a particular insurance claim. The user keys the claim number into the form field, clicks on the Start Query button, and gets the status of the claim in real time. Figure 3 shows the response back to the user. All of this is accomplished with the IBM gateway, Net.Data.

The screen in Figure 3 is a unique, dynamically created Web page that is tailored to the user, based on the claim number entered on the fill-in form. Net.Data allows the developer to create dynamic pages using data in their application databases by using a high-level macro language, thus shielding developers from the complexities of CGI programming.

How the Sample Program Was Written

Figure 4 shows the Net.Data macro used to create and execute the sample application. Net.Data macros have four key parts: an input section denoted by the %HTML_INPUT macro; a define variable section denoted by one or more %DEFINE macros; a report section denoted by the %HTML_REPORT macro; and the SQL section denoted by a %SQL macro. I will give you a high-level view of how the process flows from input to response. Figure 5 shows the flow of events in a hypothetical macro.

First, a Web user navigates to an HTML link in the following form: http://as400.here.com/QSYS.LIB/CGI.


Net.Data

LIB/DB2WWW.PGM/www/XMP/input where the underlined section is the macro that the DB2WWW.PGM uses to process the request. Note that although the DB2WWW product has been renamed Net.Data, the CGI program, DB2WWW, has not been renamed. The DB2WWW.PGM is the CGI that Net.Data provides. Notice the last part of the URL, specifically the input parameter. This signals the DB2WWW.PGM to read the XMP macro and process the HTML INPUT section. The HTML INPUT section’s duty is to create an HTML document that the Web user fills in to initiate the query. When the user fills in the forms and clicks the Submit Query button, the DB2WWW.PGM CGI is again invoked with a URL much like the one above but with a minor difference: the final parameter is report instead of input. Net.Data then uses the HTML REPORT section to perform SQL operations upon the DB2/400 database and to format a dynamic Web page in response.

Figure 6 shows you the %HTML_INPUT section. Our hypothetical user clicked on a hyperlink:
http://pid400f/db2www/CLAIMQJOIN.MBR/input The Net.Data program was invoked and used the macro file CLAIMQJOIN.MBR, parsing it to find the %HTML_INPUT section that you see in Figure 6. Note that Net.Data macros are blocked, meaning that everything between the macro’s %HTML_INPUT{ and the matching %} is included in the macro. The input section builds a fill-in form using standard , , and the important
tags. As seen in this example, the
tag has an ACTION attribute in the form:

ACTION=“http://pid400f/db2www/CLAIMQJOIN.MBR/report ” Within the form are tags for an input text area and a submit button. The input area is where the user enters the claim number before clicking on the Start Query button to invoke the ACTION attribute’s URL, as noted above. The DB2WWW.PGM then finds and processes the %HTML_REPORT section.

Before looking at the report section, we should discuss Net.Data variables. In the example, notations such as $(V1) and $(TABLE) are Net.Data variables. Variables can be created in three ways.

• Variables can be created by using the %DEFINE macro. In the sample, %DEFINE TABLE = “RUSH.RFMCLAIMS” creates a macro variable, $(TABLE) that can be used anywhere in the macro.

• Variables are created automatically in the %HTML_INPUT section. In the sample, the NAME attribute in the form’s tag defines a text area named CLAIMNUM. This automatically creates a macro variable called $(CLAIMNUM).

• Net.Data macros have special variables. For instance, the $(V1) through $(Vn) variables are the data in columns for the current row returned by the SQL query, so $(V1) is the data in column one for the current row. Variables $(N1) through $(Nn) contain the column names from the database.

Refer to the Net.Data application programmers guide at this URL: http://www.software.ibm.com/data/db2/netdata.html for other special variables.

Figure 7 shows the %HTML_REPORT section. Recall that this section is processed after the user fills in the form created by the %HTML_INPUT section and clicks on the Start Query button. The report section in the example builds a dynamic page that contains the results of the Net.Data SQL statements. Like the %HTML_INPUT section, the %HTML_REPORT section uses standard HTML statements such as and

”AS/400
DB2WWW Queries on the AS/400


THE STATUS OF CLAIM NUMBER: $(claimnum)


P>
%exec_sql





%}

Figure 4: Example Net.Data Source Code


Building_Dynamic_Web_Pages_with_Net._Data07-00.jpg 450x338

Figure 5: Net.Data Macro Flow

%HTML_INPUT{


”AS/400
DB2WWW Queries on the AS/400
http://pid400f/db2www/CLAIMQJOIN.MBR/report “>

ENTER CLAIM NUMBER TO GET STATUS FOR:








%}

Figure 6: %HTML_INPUT


BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$0.00 Raised:
$

Book Reviews

Resource Center

  • SB Profound WC 5536 Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application. You can find Part 1 here. In Part 2 of our free Node.js Webinar Series, Brian May teaches you the different tooling options available for writing code, debugging, and using Git for version control. Brian will briefly discuss the different tools available, and demonstrate his preferred setup for Node development on IBM i or any platform. Attend this webinar to learn:

  • SB Profound WP 5539More than ever, there is a demand for IT to deliver innovation. Your IBM i has been an essential part of your business operations for years. However, your organization may struggle to maintain the current system and implement new projects. The thousands of customers we've worked with and surveyed state that expectations regarding the digital footprint and vision of the company are not aligned with the current IT environment.

  • SB HelpSystems ROBOT Generic IBM announced the E1080 servers using the latest Power10 processor in September 2021. The most powerful processor from IBM to date, Power10 is designed to handle the demands of doing business in today’s high-tech atmosphere, including running cloud applications, supporting big data, and managing AI workloads. But what does Power10 mean for your data center? In this recorded webinar, IBMers Dan Sundt and Dylan Boday join IBM Power Champion Tom Huntington for a discussion on why Power10 technology is the right strategic investment if you run IBM i, AIX, or Linux. In this action-packed hour, Tom will share trends from the IBM i and AIX user communities while Dan and Dylan dive into the tech specs for key hardware, including:

  • Magic MarkTRY the one package that solves all your document design and printing challenges on all your platforms. Produce bar code labels, electronic forms, ad hoc reports, and RFID tags – without programming! MarkMagic is the only document design and print solution that combines report writing, WYSIWYG label and forms design, and conditional printing in one integrated product. Make sure your data survives when catastrophe hits. Request your trial now!  Request Now.

  • SB HelpSystems ROBOT GenericForms of ransomware has been around for over 30 years, and with more and more organizations suffering attacks each year, it continues to endure. What has made ransomware such a durable threat and what is the best way to combat it? In order to prevent ransomware, organizations must first understand how it works.

  • SB HelpSystems ROBOT GenericIT security is a top priority for businesses around the world, but most IBM i pros don’t know where to begin—and most cybersecurity experts don’t know IBM i. In this session, Robin Tatam explores the business impact of lax IBM i security, the top vulnerabilities putting IBM i at risk, and the steps you can take to protect your organization. If you’re looking to avoid unexpected downtime or corrupted data, you don’t want to miss this session.

  • SB HelpSystems ROBOT GenericCan you trust all of your users all of the time? A typical end user receives 16 malicious emails each month, but only 17 percent of these phishing campaigns are reported to IT. Once an attack is underway, most organizations won’t discover the breach until six months later. A staggering amount of damage can occur in that time. Despite these risks, 93 percent of organizations are leaving their IBM i systems vulnerable to cybercrime. In this on-demand webinar, IBM i security experts Robin Tatam and Sandi Moore will reveal:

  • FORTRA Disaster protection is vital to every business. Yet, it often consists of patched together procedures that are prone to error. From automatic backups to data encryption to media management, Robot automates the routine (yet often complex) tasks of iSeries backup and recovery, saving you time and money and making the process safer and more reliable. Automate your backups with the Robot Backup and Recovery Solution. Key features include:

  • FORTRAManaging messages on your IBM i can be more than a full-time job if you have to do it manually. Messages need a response and resources must be monitored—often over multiple systems and across platforms. How can you be sure you won’t miss important system events? Automate your message center with the Robot Message Management Solution. Key features include:

  • FORTRAThe thought of printing, distributing, and storing iSeries reports manually may reduce you to tears. Paper and labor costs associated with report generation can spiral out of control. Mountains of paper threaten to swamp your files. Robot automates report bursting, distribution, bundling, and archiving, and offers secure, selective online report viewing. Manage your reports with the Robot Report Management Solution. Key features include:

  • FORTRAFor over 30 years, Robot has been a leader in systems management for IBM i. With batch job creation and scheduling at its core, the Robot Job Scheduling Solution reduces the opportunity for human error and helps you maintain service levels, automating even the biggest, most complex runbooks. Manage your job schedule with the Robot Job Scheduling Solution. Key features include:

  • LANSA Business users want new applications now. Market and regulatory pressures require faster application updates and delivery into production. Your IBM i developers may be approaching retirement, and you see no sure way to fill their positions with experienced developers. In addition, you may be caught between maintaining your existing applications and the uncertainty of moving to something new.

  • LANSAWhen it comes to creating your business applications, there are hundreds of coding platforms and programming languages to choose from. These options range from very complex traditional programming languages to Low-Code platforms where sometimes no traditional coding experience is needed. Download our whitepaper, The Power of Writing Code in a Low-Code Solution, and:

  • LANSASupply Chain is becoming increasingly complex and unpredictable. From raw materials for manufacturing to food supply chains, the journey from source to production to delivery to consumers is marred with inefficiencies, manual processes, shortages, recalls, counterfeits, and scandals. In this webinar, we discuss how:

  • The MC Resource Centers bring you the widest selection of white papers, trial software, and on-demand webcasts for you to choose from. >> Review the list of White Papers, Trial Software or On-Demand Webcast at the MC Press Resource Center. >> Add the items to yru Cart and complet he checkout process and submit

  • Profound Logic Have you been wondering about Node.js? Our free Node.js Webinar Series takes you from total beginner to creating a fully-functional IBM i Node.js business application.

  • SB Profound WC 5536Join us for this hour-long webcast that will explore:

  • Fortra IT managers hoping to find new IBM i talent are discovering that the pool of experienced RPG programmers and operators or administrators with intimate knowledge of the operating system and the applications that run on it is small. This begs the question: How will you manage the platform that supports such a big part of your business? This guide offers strategies and software suggestions to help you plan IT staffing and resources and smooth the transition after your AS/400 talent retires. Read on to learn: