29
Fri, Nov
0 New Articles

Programming Strategies:HTML, CGI, JavaScript, ASP/ADO, DHTML, and XML

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

Today’s Web developers go beyond the use of basic HTML. Now, they are able to select from a variety of strategies that enable their Web sites to become robust. This article begins by describing basic HTML and then overviews host programming with CGI and ASP, and client programming with JavaScript. The article continues with a discussion of advancements to the HTML language with DHTML before closing with the introduction of XML, a language that effectively replaces HTML.

Today, numerous Internet programming strategies abound—some of them more prevalent than others. This article provides an overview of the strategies that I have used in the course of my career as a Webmaster. The accompanying article by Don Denoncourt zeroes in on strategies that he has used in the course of his career as a systems programmer and more recently as the editor of AS/400 NetJava Expert (see “Programming Strategies: Applets, Servlets, Sockets, Distributed Objects, and Vendor Specific” elsewhere in this Focus section). By reading both of these articles, you will acquire a general knowledge from which you can begin to consider what programming strategies you should use in the design of your company’s Internet site.

HTML, or Hypertext Markup Language, is the meat and potatoes of today’s Internet. Even though plenty of newer technologies are available, most of the information available on the Internet today is made available through HTML files. HTML contains commands, called elements or tags (strangely similar to the AS/400 User Interface Manager, or UIM) to “mark up” text such as headings, paragraphs, lists, menus, and tables. A Web browser is able to read HTML files and present them in a fashion that is visually appealing in the form of a Web page (see Figure 1). HTML allows you spice up these Web pages with images, sound, and even video clips.

The hyper in HTML refers to tags that link a Web page to other Web pages or Internet resources. The destination of that link can be local, or it can be completely across

HTML

the world if the link contains a global address called a Uniform Resource Locator (URL). The rise of power and popularity of the Internet started from its ability to link documents that reside on various platforms spanning the globe.

One of the best things about this formatting language is that it is easy to understand, even for nonprogrammers. It can be learned by almost anyone with a few evenings to spare. The formatting tags, which are written in plain English, are interpreted by the browser. The browser, in turn, displays the output Web page. The idea is that HTML permits any kind of computer—Macs, PCs, Suns, etc.—to interpret a document in approximately the same way.

The problem with HTML files is that they are static: The content of the Web page doesn’t change. Internet applications need the ability to accept and respond to remote user input in data-entry form. The most common way to capture data is by the use of HTML forms, which give the user the ability to enter relevant data that can then be submitted back to the Web server (in a strategy similar to 5250 applications). Currently, static HTML cannot do this without the assistance of Internet programming. For a Web page to capture data from a user and then to transmit that data to the host for processing requires an additional degree of Web programming.

One method of Web programming is Common Gateway Interface (CGI). CGI is a standard for interfacing legacy host-based applications with Web servers. A CGI program is executed in real time so that it can output dynamically constructed HTML rather than the static information of basic HTML files. Using the form mail example, the Web page needs to send information to a mailer program so that it can be handled and sent off to its destination in a usable format. This is an example of a gateway, the idea behind CGI.

If you’re writing a CGI application, you use whatever flavor of computer language you prefer, whether it be C, Visual Basic, Fortran, AppleScript, Perl, etc., as long as the platform of your Web server supports them. On the AS/400, this flexibility means you can code Internet applications with your old and faithful RPG and COBOL.

One problem with CGI applications is that its “openness” allows anyone to run an executable program on your server, which can pose a serious security issue. The point is, the more sophisticated your Web site becomes, the more security becomes an issue. Most Web developers would probably agree that the future of the Internet is in database-driven Web sites. If your Web site doesn’t have database connectivity, you might already be falling behind, and CGI is the easiest way to catch up.

JavaScript

First, let me point out that JavaScript is not Java. In fact, when Netscape first introduced a scripting language, they called it Live-Script, not JavaScript. But Netscape’s marketing department, to jump on the media frenzy surrounding Java, renamed Live- Script. Netscape’s stock rose $20 the day that “JavaScript” was announced. At any rate, whatever the name of this scripting language might be, it was designed to make some HTML-related tasks much easier. JavaScript is a small, simple, interpreted language that is much easier to learn than full-blown applications languages like RPG and Java. JavaScript, unlike CGI, runs on the client, so it has full access to the browser and knows what the user is doing. JavaScript enables page designers to access events, such as mouse clicks, and to paste together HTML, plug-ins, and Java applets.

The problem with JavaScript is that it is simple and you can only use it to perform simple tasks. JavaScript mainly is used for the creation of user interfaces that are more sophisticated than basic HTML because JavaScript can respond to user events by dynamically reformatting the presentation of a Web page.

Active Server Pages

Although CGI can be used to generate output that can be ported to a database—if you are running the Microsoft Internet Information Server (IIS) as your Web server—amuch better solution might be Active Server Pages (ASP). This is Microsoft’s latest Web-

CGI

programming strategy. ASP allows Web site developers to make their pages even more dynamic and interactive (see Figure 2). ASP is particularly useful because it means developers won’t have to abandon their current CGI programs and custom components as long as they’ll run on IIS.

For example, instructions can be included in an ASP file that will execute an existing CGI application; the application simply runs as it would have if it had been referenced directly in the browser. Yet, with ASP, the browser actually references the page that it wants, and that page is then read into memory as if it were a normal, static page. But before the Web page is transmitted back to the browser, the IIS server examines the Web page for any script that it should be handling. It then executes such a script. This script can calculate and insert values into the page or create extra text and HTML code, as required. And, because it works directly on the page while it’s loaded instead of creating a “results set” first, it gives you control over how the finished page will appear.

Once the server has finishing modifying the loaded page, it packages it up in the HTTP wrapper and sends it off to the browser. When it arrives there, it’s just text and HTML code, like a normal, static page. In this case, the browser will reference the file that is returned, but it’s a modified copy of this file (containing the results of executing any script in it) that the user sees. The process is more akin to writing an application than creating an HTML page.

One of the main reasons for using dynamic pages in a Web site is to provide database access. This access may mean simply retrieving values to display, such as a company’s list of currently available products and their latest prices. Alternatively, the site may want to collect information from the user and store this information in a database. One of the standard server components supplied with ASP is specially designed to do just that. The ActiveX Data Object (ADO) can provide full access to almost any database system for which an ODBC driver is available. ODBC allows you to use this single component with different database systems, thus simplifying the process of creating and maintaining your Web site. For example, Microsoft Access has a wizard that allows you to create an ASP page from an existing database.

Dynamic HTML

CGI, ASP, and ADO give us the tools to enable our Web site to capture and serve dynamic data, but what about making a site’s overall appearance more interesting and cutting edge? Regular HTML can’t offer much in the way of multimedia tools. There are alternatives such as Macromedia Shockwave and Flash, but there is a problem with such plug-in tools: They limit the audience of your Web page. Visitors to a Web page that uses a plug-in tool must download and install that tool on their machine before they can view the page. In order to achieve the same results from your Web page while not excluding those without the latest plug-ins, there is Dynamic HTML (DHTML).

A standard HTML document cannot specify that text and images be located at exact coordinates, on top of one another, or even that the text be displayed in a particular point size. Until now, Web authors have struggled to get browsers to display HTML content exactly the way they want it. DHTML allows content to be displayed with more design flexibility and accuracy through the use of Cascading Style Sheets (CSS). Using CSS, Web authors can define fonts, margins, and line spacing for different parts of an HTML document. In addition to these stylistic improvements, CSS allows the absolute positioning of content by specifying x and y coordinates (and even a z index, which allows different elements to overlap).

DHTML improves the functionality and interactivity of an HTML document. It also works with scripting languages, such as JavaScript and VBScript, that provide developers with more control over an HTML document. With DHTML, Web page content becomes more flexible, and text, images, and other objects can be hidden, shown, and rearranged around the page. Also, awareness of user actions is expanded, allowing keystrokes and a larger variety of mouse actions to be interpreted by scripting languages. With dynamic

creation of content, a Web page can be created and displayed without reloading or redrawing a document. Although the ability to create content “on the fly” existed before DHTML, it required the entire document or frame to be redrawn. DHTML has no such requirement. For example, with DHTML, stock quotes can be tabulated and displayed as they change.

DHTML also takes into account how important database connectivity is. Closely related to the dynamic creation of content is data binding, a feature supported by Internet Explorer 4.0 through CSS properties. Data binding allows the server and the client to be connected. The data in a database can be bound to tables or form elements in an HTML document. Information from a database can be displayed in a table that’s automatically generated, and then that data can be dynamically updated or sorted—through a script—without redrawing the page.

One thing to watch out for is that DHTML has two drastically different implementations: Netscape’s version, and Microsoft’s version. DHTML elements that work on Netscape Navigator will probably not work on Internet Explorer, or at least, not in the way that you intended.

HTML is no longer the only game in town. Now, there is a new specification called eXtensible Markup Language (XML). Both XML and HTML are subsets of Standard Generalized Markup Language (SGML), a system for organizing and tagging elements of a document that was developed and standardized by the International Organization for Standardization (ISO) in 1986. The Web industry at large is only now beginning to discover the limitations of the HTML incarnation of SGML. SGML, for instance, has a number of sophisticated features that HTML does not: extensibility, structure, and validation. XML, unlike HTML, was designed to retain the powerful extensibility of SGML. But XML, like HTML, was also designed to be simple. As a result, XML is vastly easier to learn and implement than SGML.

The extensible part of XML comes into play when an organization (such as a trade association) decides to specify an industry-specific set of descriptive markup tags. These tags don’t say how to format the document, nor do they say what to do when people click on the tag.

In fact, XML is really a meta-language for describing markup languages. In other words, XML provides a facility to define tags and the structural relationships between them. The power of XML manifests itself when you show a document on, for example, a big monitor or, for that matter, a tiny cell phone. A different set of rules is defined to apply to the monitor display of the document versus the cell phone display of that same document. XML effectively “decouples” the document from its presentation. This decoupling certainly doesn’t make documentation presentation any easier, but it does make it far more powerful.

After an organization defines a set of industry-specific XML tags, they are published in what is known as a document type definition (DTD). One DTD could describe a lot of different documents. You could almost compare DTDs with SQL database schemas. You could, in fact, say that DTDs are schemas for documents.

More Strategies

The strategies in this article are clearly not the only Internet programming strategies. They are, however, strategies that are extremely popular and in heavy use today. Even XML, which has only recently been introduced, is already being used by many companies. Why? Because it provides a solution to requirements that HTML didn’t deliver.

Being aware of the requirements for Internet applications programming, discovering the strategies that meet those requirements, and then producing a powerful Web site is what my job as Webmaster is all about. So, too, will it be a part of your job as legacy applications are becoming more and more integrated with the Internet.

XML

Static HTML





Programming_Strategies-_HTML__CGI__JavaScript...05-00.png 87x102




Web Browser



Programming_Strategies-_HTML__CGI__JavaScript...05-01.png 116x79

Web Browser

HTML Page Requests HTML Page




HTTP Web Server



Programming_Strategies-_HTML__CGI__JavaScript...05-07.png 137x79

HTTP Web Server

Static HTML

Figure 1: HTML files reside on the platform of your Web server and are dynamically downloaded to browsers upon a user’s request

Request Page

HTTP Encoding





Programming_Strategies-_HTML__CGI__JavaScript...05-09.png 100x137





Programming_Strategies-_HTML__CGI__JavaScript...05-13.png 95x102

Client

Server





Programming_Strategies-_HTML__CGI__JavaScript...05-02.png 95x97





Programming_Strategies-_HTML__CGI__JavaScript...05-03.png 66x77





Programming_Strategies-_HTML__CGI__JavaScript...05-05.png 116x81




Active Server Pages

Add the HTTP Wrapper



Programming_Strategies-_HTML__CGI__JavaScript...05-08.png 139x79

Active Server Pages




VB Script or Java Script

Dynamic Page



Programming_Strategies-_HTML__CGI__JavaScript...05-10.png 139x81

VB Script or Java Script




Disk



Programming_Strategies-_HTML__CGI__JavaScript...05-14.png 62x47

Disk




HTTP Decoding



Programming_Strategies-_HTML__CGI__JavaScript...05-04.png 116x81

HTTP Decoding





Programming_Strategies-_HTML__CGI__JavaScript...05-06.png 116x81





Programming_Strategies-_HTML__CGI__JavaScript...05-11.png 170x81





Programming_Strategies-_HTML__CGI__JavaScript...05-12.png 116x81

Figure 2: Active Server Pages generates dynamic, interactive Web pages

BLOG COMMENTS POWERED BY DISQUS

LATEST COMMENTS

Support MC Press Online

$

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: