|
|||||||
|
|
![]() |
|
|
An Alternative Method of Serving Web Pages from AS/400 by Shannon O'Donnell [The code for this article is available for download.] What ever happened to good old days of DDS and RPG? Sadly, especially for those who refuse, or are unable, to learn, the days of 5250 and RPG programming are ending fast. Today's users are rather sophisticated, and they expect to get the same level of functionality and aesthetics from the computer screens at their jobs that they get at home while playing on the Internet. Today's users don't want a green screen. They want Web pages. So Many Choices In today's AS/400 shops, there are many ways to give your users access to Web pages served from your AS/400. One way--which is IBM's suggested method--is to use IBM WebSphere Site Studio Developer (WSSD), or the new version, WebSphere Development Studio client (WDSc), to design and build professional-quality Web pages and JavaServer Pages. Of course, going this route requires a tremendous investment in time and money in educating yourself and your shop in using the WSSD or WDSc toolset, as well as in Java and JavaServer Pages programming. You also will need to learn all about the iSeries HTTP server, the WebSphere or Tomcat application server, the Integrated File System, Web browser security, and many other unique and new paradigms. Even if you use the WebFacing tool to convert your DDS into Web pages, you still will need education on some of these technologies. In fact, if you are still programming in RPG and DDS and have never even written a simple HTML page or configured your iSeries HTTP server, you have a long road ahead. Another method for serving Web pages from your AS/400 is to serve them directly from the Integrated File System, via the AS/400's HTTP server. This method also requires that you learn about the HTTP server and the IFS, but it is not nearly as complex as the previous method. Of course, it doesn't provide the functionality and flexibility of the technologies mentioned above. But the point is, you have choices. For a complete, step-by-step tutorial on how to use the HTTP server to serve static Web pages, check out the article "Displaying Static HTML Pages from the iSeries." In this article, I'm going to show you yet another way to display static Web pages from your AS/400. This time, by using a Visual Basic program and the Microsoft Web browser Control ActiveX component. What the Example Does In this example, we are going to build a few simple Web pages, copy them to our AS/400's Integrated File System, and then build a VB application that uses the Web browser control to display those Web pages. Let's take a look at the various parts. The Visual Basic Parts If you are a die-hard AS/400 programmer, you are probably already cursing me at this point. The last time I wrote about using Visual Basic as a solution for an AS/400 problem (in "Display Operations Navigator from a 5250 Green Screen"), I received quite a bit of e-mail from readers who were outraged that I'd dare suggest a Microsoft solution for the AS/400. Well, my feeling has always been that you use whatever tool is right for the task at hand. Sometimes it's AS/400 tools only, and sometimes it's a combination of AS/400 and other vendor products, like Microsoft's Visual Basic. In any event, if you want to be daring and break out of your AS/400 RPG shell, read on. For this article, we'll be using Visual Basic 6.0 and the Microsoft Web Browser Control. If your shop does not have VB 6.0, you can purchase it as a stand-alone product from a variety of sources on the Web and in the major electronic retail outlets for under $100. That's a pretty cheap investment for something that is so versatile and useful. The Web Browser Control is an ActiveX component that comes standard with the Internet Explorer browser, so if your PC has Internet Explorer 5.0 or above, then you have the Web Browser Control, too. Coding the Application I'm going to assume you already know how to code a simple VB application and will move forward from that base of operations. Here are the steps you need to take to build the VB application for this article:
Public Sub Form_Load() WebBrowser1.Navigate2 "http://AS400Server:6080/AS400WebSite/Page1.htm" End Sub Public Sub Command1_Click() Unload Me End Sub Private Sub Command2_Click() WebBrowser1.GoBack End Sub Private Sub Command3_Click() WebBrowser1.GoForward End Sub Private Sub Command4_Click() WebBrowser1.GoHome End Sub In this code, we are using several methods of the Web Browser Control. Initially, we use the Navigate2 method to tell the control which page to navigate to when the form first loads. This should be your index page on your AS/400. As the users click around on your Web site and drill down to basic-level pages, they can then use the Web Browser Control's GoBack, GoForward, and GoHome methods to navigate through your site. In other words, for a minimal amount of coding, you get the entire functionality of a standard Web browser! Now save your project. The AS/400 Parts The only thing you need to do on the AS/400 is configure your HTTP server. If you followed the instructions for displaying static Web pages in "Displaying Static HTML Pages from the iSeries," you've got this part licked. If you use a port other than 7080 (and you can use any port you desire), be sure to change the port number in the VB code shown above. The only other thing that I'll suggest you do is to create a separate, subdirectory below the parent directory you configure for serving Web pages on your AS/400. Name this subdirectory AS400WebPages. By using this name, you won't need to change any of the code for the sample to work. The Web Pages You can use any Web pages you like for this example, or you can use the ones included with the downloadable code for this article. Regardless of whether you create your own or use ours, be sure to copy the Web pages and any images or other materials to the AS400WebPages subdirectory on your AS/400. Putting It All Together Now it's time to put it all together. Start the HTTP server instance you created, and then fire up the VB program. If you configured everything correctly, the Web page address used in the Navigate2 method of the Web Browser Control will automatically open the Web page on your AS/400. As users drill down to other Web pages on your site, the Web Browser Control will automatically display those pages. By leveraging the power contained in the Web Browser Control and in Visual Basic, you have just added a new weapon to your programming arsenal, one that doesn't require you to spend weeks learning, but, instead, allows you to begin serving Web pages to your users in a unique and innovative way.
|
Editors
Contact the Editors |
| Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved. |