Back in 1996 Mel Rothman, then working with IBM's Partners in Development (PID) group, developed the original CGIDEV, also known as Easy400. Since then, CGIDEV has gone through multiple enhancements and developments (now CGIDEV2) from Mel and Giovanni Perotti of IBM Italy. Although Mel has since left IBM, you will still find him (along with Giovanni) answering questions and offering advice on the Easy400 group at http://groups.yahoo.com/group/Easy400Group/. So what is CGIDEV2? The simplest description is that it is a set of subprocedures that make the CGI APIs easy to use and allow you to have HTML externally described for an RPG program. On top of the simple description you can add a host of other tools (for e-mail and security), a few sample applications and a handful of tutorials to make your integration of RPG and the Web an easy one. If you want to get a feel for what CGIDEV2 has to offer, go to http://www-922.ibm.com, follow the Deliverables link (on the left) and click on the RPG CGI program development toolset link. Have a look at any of the offerings on the resulting page. Installing CGIDEV2
'); // -->
le to your iSeries, restore a library and run a couple of setup programs that will re-create the CGIDEV2 programs, create required directories and create an Apache server (or traditional server if you are still on V5R1). Make sure you follow the instructions at the top of the configuration file displayed during the install process. You may want to download and install some of the other offerings: I recommend a minimum of the E-Commerce CGI Centaur Demo (an application along the lines of Amazon, complete with source code) and the HTML and CGI Self-Study Class. Take a couple of hours to look at what you have installed. Have a look at the Yacht World demo that is installed as part of CGIDEV2. Then have a go at creating your own CGIDEV2 program. You can use some of the templates provided or you may want to try the following which is a simple "print" style program that produces a Web page like the one shown in Figure 1. This program simply lists the contents of a database to the Web page, but since we are using HTML, it seemed like a good idea to include a picture of the items being listed. Why not change the code to use one of your databases? [TABLE]Figure 1: Output from a simple "print" style CGI program What do you need? You will need a directory in the root file system to store HTML documents, style sheets, images and anything else you can think of: I am using a directory called cgiseminar. The images of the items are in a subdirectory called images: each image is a JPG and the name is a 'P' followed by the product code, e.g. the image for product 0000001 is P0000001.JPG. It is possible to store HTML documents as source members in a source physical file, but I have always found it easier to develop them on a PC and simply copy them to a directory on the IFS. Finally, you need to configure an HTTP server to use. The server should send all CGI requests to the library mentioned above. (Please refer to "How Does RPG Talk to a Browser" for detail on configuring an HTTP server.) In my example I am mapping the default CGI director of cgi-bin to the library QSYS.LIB/CGISEMINAR.LIB. The HTML The important thing to remember when designing a Web page that will be written to from a program is to only define a repeating line once. Think of the way you define a print file; you only define one record for printing and write it multiple times. In the example in Figure 2 there is the definition of one product line. When you have the Web page looking the way you want, it is time to add the CGIDEV2 bits. That means adding the equivalent of format names and field names. In Figure 2 note the lines containing /$top, /$tableline and /$end. These are the three formats that will be written from the program. '/$' is used to indicate a format name, although you do have the option of changing this and using other characters. Likewise, fields are identified by enclosing the name between a '/%' and a '%/', as with /%today%/ and /%prodcd%/. The other important point is the first line of HTML. This must be 'Content-type: text/html' followed by two carriage return/linefeed for HTML that will be written from a CGI program. Figure 2: HTML for a CGIDEV2 program The program Figure 3: A simple CGIDEV2 program The important items to note are as follows: Running the program Once the server is running, you open your browser and enter the URL of: By having the URL above as a link on a Web page you could have the information available to the user in the click of a mouse. Up and running ---------------------------
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| iSeries Security - Security Tools, Physical Security and System Security |
| About Us | Contact Us | For Advertisers | For Business Partners | Site Index | RSS |
|
|
|
|||||||