Web Enabling AS/400 Applications with IBM WebSphere Studio

Size: px
Start display at page:

Download "Web Enabling AS/400 Applications with IBM WebSphere Studio"

Transcription

1 Web Enabling AS/400 Applications with IBM WebSphere Studio Fernando Zuliani, Bob Maatta, Igor Gershfang, Robert Hare, Biswanath Panigrahi International Technical Support Organization SG

2

3 International Technical Support Organization SG Web Enabling AS/400 Applications with IBM WebSphere Studio April 2000

4 Take Note! Before using this information and the product it supports, be sure to read the general information in Appendix B, Special notices on page 407. First Edition (April 2000) This edition applies to the IBM WebSphere Studio Version 3.0 and the IBM WebSphere Application Server, Standard Edition, Version 2.0 for use with OS/400 V4R4. Comments may be addressed to: IBM Corporation, International Technical Support Organization Dept. JLU Building Highway 52N Rochester, Minnesota When you send information to IBM, you grant IBM a non-exclusive right to use or distribute the information in any way it believes appropriate without incurring any obligation to you. Copyright International Business Machines Corporation All rights reserved. Note to U.S Government Users - Documentation related to restricted rights - Use, duplication or disclosure is subject to restrictions set forth in GSA ADP Schedule Contract with IBM Corp.

5 Contents Preface...vii The team that wrote this redbook... vii Commentswelcome...viii Chapter 1. Introduction to the IBM WebSphere family The IBM WebSphere Application Server WebSphere Studio WebSphere Performance Pack WebSphere Site Analyzer Putting it all together Chapter 2. Installation and configuration Introduction to WebSphere Application Server for AS/ Installationconsiderations Installing IBM WebSphere Application Server (V4R4) Installing IBM WebSphere Application Server (V4R3) Considerations when upgrading from V4R3 to V4R Configuring the WebSphere Application Server for AS/ Addingdirectives TestingyourHTTPserverconfiguration ConfiguringtheAS/400ToolboxforJava Troubleshooting the WebSphere Application Server Installationandconfigurationonotherplatforms WebSphere Application Server Administration...20 Chapter 3. WebSphere Studio tools StudioWorkBench Creatinganewproject StudioWizards ImportinganexistingWebsite Database Wizard PublishingtheWebsite PublishingtotheAS/400system Previewing the Demo Company Web site More WebSphere Studio Wizard examples Page Designer Using WebArt Designer and AnimatedGif Designer to add enhanced graphics Constructing the Logon page Creating a page template Working with style sheets Using Page Designer with JavaBeans Modifying the Studio Wizards generated result page Applet Designer Creating an applet with Applet Designer Placing a Rollover button on the applet and connecting it to a URL Creating nervous text on the applet NetObjectsScriptBuilder VisualAge for Java 3.0 Professional Edition Copyright IBM Corp iii

6 Chapter 4. Restoring the ABC Company Web site sample project Installingthedownloadfiles Creating the WebSphere Studio project using the archive file Restoringtheprojectarchivefile Updating the ABC Company project files to use your AS/400 server CreatinganAS/400userprofile Setting up the AS/400 system to run the ABC Company Web site PublishingtotheAS/400system Packaging the WebSphere Studio application ABC Company Web site configuration Chapter 5. Order Entry application OverviewoftheOrderEntryapplication The ABC Company The ABC Company database Acustomertransaction Applicationflow Customertransactionflow Database table structure Order Entry application database layout Database terminology Chapter 6. Enabling the Order Entry application: Methodology Identifying the AS/400 application to Web-enable PrimaryusersoftheWebapplication Identifying issues and assumptions Analysis of the AS/400 application: Business and presentation logic Web-sitedesign DividingtheWebsiteintosubsitesbasedonfunctionality Subsitedevelopmentandunittesting Tying it all together Integrationtesting Summary Chapter 7. ABC Company Web site design and development Login and session management Creatingtheloginservlet Building the custid bean Building a session management servlet Creatingthenewuserssubsite Newusers:DevelopmentontheAS/400server New users: Development using WebSphere Studio tools Input data validation Newusercreationsummaryandfinaltesting Creatingthecatalogsubsite Creatingthecatalogproject Creating the SQL queries for the catalog subsite Creating the Web pages for the catalog subsite Testing the catalog pages Creating the general catalog area Linking the catalog pages Shopping cart subsite Creating the shopping cart project Creating the SQL queries for the shopping cart subsite iv Web Enabling AS/400 Applications with IBM WebSphere Studio

7 7.4.3 Creating Web pages for the shopping cart subsite Testing the shopping cart pages Modifying the shopping cart bean to display item totals Linking the shopping cart pages Changing the quantities of the items in the shopping cart Testing the updated shopping cart for changing item quantities Deleting items from the shopping cart Testing the updated shopping cart for deleting items Creatingtheorderpurchasesubsite Creatingtheorderpurchaseproject CreatingSELECTSQLfortheSHPCARTtable Creating servlet and DB access bean for SHPCART select query Modifying the resulting page of the shopping cart selection Creating the servlet, DB access bean, and JSPs to submit the order Developing Java code to package and submit the order to the AS/400 server CallingtheAS/400serverprogramtosubmittheorder Order confirmation: Creating SELECT SQL for the ORDERS table Creating servlet and DB access bean for the ORDERS select query CreatingtheDELETESQLfortheSHPCARTtable Creating the servlet and DB access bean for the SHPCART delete Error handling on order submission to the AS/400 server Creatingaself-containedorderpurchasesubsite Orderpurchasesubsite:Finaltesting Changes to the Host Order Entry application Processingthesubmittedorder Summary Creatingtheorderstatussubsite Creatingtheorderstatusproject Building the SQL queries for the order status subsite Using the SQL queries in the Database Wizard Testing the Order Status pages Joiningtheorderstatuswiththeorderline Testingtheorderstatussubsite Chapter 8. Creating the complete ABC Company Web site Websitedevelopment:Issuesandpitfalls Designobjectives Production Publicizing EvaluatingtheWebsite Creating static pages Content of static HTML pages Working with existing pages Creating images for all links Creatingthenormalandregisteredusertemplates Normal page templates Registeredusertemplates Session management servlet, login servlet, and custid bean Assembling the ABC Company Web site Adjusting the links on the static pages Modifying the Welcome page Modifying the About Us page v

8 8.4.4 Modifying the History page Modifying the Logout page Tying it all together Importingthesubsites Cleaning up subsites Organizing the servlet folders Fixingbrokenreferences Addingregisteredusertemplates Restructuringdirectories Login page The Welcome Registered User page Linking the Login page Linking the Registered User pages together Finaltouches PublishingtheWebsite Heading towards e-commerce Tasksummaryandintegrationtesting Integrationtesting Summary Knownproblems Appendix A. Example programs A.1 DownloadingthefilesfromtheInternet A.2 ReadMe file Appendix B. Special notices Appendix C. Related publications C.1 IBM Redbooks publications C.2 IBM Redbooks collections C.3 Otherresources C.4 ReferencedWebsites How to get IBM Redbooks IBM Redbooks fax order form Index IBM Redbooks review vi Web Enabling AS/400 Applications with IBM WebSphere Studio

9 Preface In the past two decades, the way the world does business has changed dramatically. The Internet has played a crucial role in this development. A business without some kind of presence on the Internet today would be a rare occurrence. Historically, Web sites were static but, in the past few years, interest in taking advantage of the ability to provide interactive contents has increased dramatically. This redbook explores some of the tools and techniques that can be used to bring the contents of an existing AS/400 application to the Web. The vehicle used to accomplish these tasks is the IBM WebSphere Application Server Standard Edition 2.0, which ships as part of OS/400. The tools suite used in this redbook includes the IBM WebSphere Studio 3.0 and the AS/400 Java Toolbox. You learn how to create Web-based applications that not only interact with traditional DB2/400 databases, but also with RPG programs and other AS/400 specific features. Prior to reading this redbook, you should be familiar with the Java programming language, Web Technologies (HTML, browsers), and Web servers. The team that wrote this redbook This redbook was produced by a team of specialists from around the world working at the International Technical Support Organization Rochester Center. Fernando Zuliani is an IBM Certified Professional (I/T Specialist) working in the International Technical Support Organization (ITSO) in Rochester, USA. He has worked at IBM for 12 years and has over 14 years of professional I/T experience. His areas of expertise include AS/400, client/server programming, application development, object-oriented technology, and performance. Currently, he is the ITSO Project Leader for WebSphere, Java, and XML. He holds a bachelor of science degree in mathematics from the University of Sao Paulo, Brazil. Bob Maatta is a Senior Software Engineer from the United States at the IBM International Technical Support Organization, Rochester Location. He is the ITSO technical leader for AS/400 e-business application development. He writes extensively and teaches IBM classes worldwide on all areas of AS/400 client/server and e-business application development. Before joining the ITSO in 1995, he worked in the AS/400 National Technical Support Center as a Consulting Market Support Specialist. He has over 20 years of experience in the computer industry. He has worked on numerous computer platforms including S/390, S/38, and AS/400 and has worked with all aspects of personal computers since He is a Sun Certified Java Programmer and a Sun Certified Java Developer. Igor Gershfang is an Information Technology Architect with IBM Global Services. Currently he specializes in creating e-business solutions and Web-enabling existing application systems using a variety of development tools. His background is in application development and systems integration, which has gradually evolved into information technology architecture. He possesses expert-level knowledge of the AS/400 platform in terms of application development. His areas of expertise also include Java, C, C++, ILE RPG, DB2, and other RDBMSs. He is currently working in the IBM e-business Solution Center in Chicago, Illinois, where he is mastering the WebSphere Application Server and WebSphere Studio tool set. Igor holds a bachelor's degree in computer science. Copyright IBM Corp vii

10 Robert Hare is an Internet Specialist at Mid-Comp International, an Australian-based IBM Business Partner. He has been working in the industry for the past two years on the Internet and AS/400-related projects. He has expertise in Java, Object Oriented design, HTML, and Internet security. He holds a degree in physics and computing from Victoria University of Technology, Australia. Biswanath Panigrahi is a Technical Specialist working in the Partner in Development (PID) in Bangalore, India. He has worked at IBM for two years and has over three years of professional I/T experience. His area of expertise include AS/400, client/server programming, Domino, Web-based application development, and performance. He holds a master's degree in computer applications from Orissa University of Agriculture and Technology, Bhubaneswar, India. Thanks to the following people for their invaluable contributions to this project: Greg Hester Vice President, CrossLogic Corporation, USA Makoto Nishino IBM Japan Brad Hanks Cindy McCrickard Jenny Szawlewicz IBM Raleigh Richard Salz IBM Rochester Dave Russell Oma Sewhdat Toronto lab, IBM Toronto Comments welcome Your comments are important to us! We want our Redbooks to be as helpful as possible. Please send us your comments about this or other Redbooks in one of the following ways: Fax the evaluation form found in IBM Redbooks review on page 423 to the fax number shown on the form. Use the online evaluation form found at Send your comments in an Internet note to redbook@us.ibm.com viii Web Enabling AS/400 Applications with IBM WebSphere Studio

11 Chapter 1. Introduction to the IBM WebSphere family WebSphere is a brand name for a set of IBM products designed to make it easier and more productive to build, deploy, and manage a dynamic Web site. WebSphere is architected to enable you to build business-critical applications for the Web. The IBM WebSphere family consists of the following components: WebSphere Application Server WebSphere Studio WebSphere Performance Pack WebSphere Site Analysis To keep up to date on IBM WebSphere support, visit the Web site: The IBM WebSphere Application Server As the popularity of Java continues to increase, the emerging program model that people are expected to move to is the application server model. The IBM offering for the AS/400 system is the WebSphere Application Server. It is a Java-based servlet engine that s built on top of the native Java virtual machine on the AS/400 system. It provides Java servlet API support, which is defined by Sun Microsystems. If you write to the Java servlet API standard, your application is portable across any operating system, and any environment that supports servlets. This is a big reason why this is becoming a very popular interface to whichtowrite. The WebSphere Application Server comes with a graphical user interface to manage servlets and control who has access to them. Since most applications are going to access a database, there are many advanced database access capabilities available. This includes a connection manager to improve performance when accessing remote databases and data access beans that makes accessing the database even easier for Java programmers. The WebSphere Application Server also comes with JavaServer Pages (JSPs) support. The JavaServer Pages technology is a simple but powerful way to dynamically generate HTML pages on the server side. With JavaServer Pages technology, you can quickly and easily create Web pages with dynamically generated content. When you write JavaServer Pages, you call reusable server components (such as JavaBeans or servlets) to automatically create data objects from an HTML file. This allows you to cleanly separate the generation of dynamic content from its presentation. There are three versions of the WebSphere Application Server: Standard Edition: The Standard Edition is intended for use by Web application developers who focus on the issues of presentation logic, data access, and the business logic that resides in the middle tier. The focus is on servlet run times, HTML, and support for JavaServer Pages. This combination provides an easy-to-use set of capabilities for presentation and data access-oriented Web applications. Advanced Edition: The Advanced Edition adds support for Enterprise JavaBeans (EJB). The EJB support includes bean-managed and session-managed persistence using entity beans, full support for session Copyright IBM Corp

12 beans, relational database connectivity using JDBC (allowing support of the Java Transaction Service, (JTS) using EJBs), and support for EJBs to MQSeries and CICS for even more robust transactional support. Enterprise Edition: Integrating enterprise applications is the focus of the Enterprise Edition. This edition adds to the EJB and services support of the Advanced Edition. The ability to integrate applications across the enterprise using the robust architecture and services is provided as part of the CORBA standard. The Enterprise Edition leverages the connectivity and application integration capabilities of IBM Component Broker technology, which has been incorporated into WebSphere. In addition, users can deploy EJBs either to the same EJB container that is part of the Advanced Edition or to the Component Broker container. The AS/400 system provides WebSphere Application Server support starting with V4R3. In V4R3, WebSphere Application Server 1.1 support is provided as part of the HTTP Server for AS/400 (5769-DG1). In V4R4, it is split out into a separate product called 5769-AS1, which is still at Version 1.1. For V4R4, you can upgrade to the new Standard Edition Version 2.0 via PTFs. For more information on using WebSphere Application Server Standard Edition 2.0 in an AS/400 environment, see Building AS/400 Applications for WebSphere Standard Edition 2.0, SG In 2000, Version 3 of the WebSphere Application Server Advanced Edition for AS/400 will be available. It provides support for Enterprise JavaBeans and Enterprise Java Services. EJB components are reusable and portable server-side business logic components. IBM has adopted the EJB model to deliver productivity and flexibility to customers who are building sophisticated Web applications. This unified component model, supported across the IBM product line, makes it easier for customers to build, run, and manage the new generation of e-business applications, using tools and platforms that best meet their business needs. Enterprise Java Services are the IBM-provided functions that run and manage applications coded to the EJB specification. The container and server provide transaction, security, and persistence support, which makes development of server-side business logic considerably easier. 1.2 WebSphere Studio WebSphere Studio is a suite of tools for the development of Web applications. It is optimized specifically for WebSphere Application Server applications. However, you can also use many of the Studio tools for the development of applications for other Web servers or Web application servers. You run the WebSphere Studio development tools on a Windows workstation. You can deploy the resulting application to an AS/400 system running either WebSphere Application Server Standard Edition or Advanced Edition. WebSphere Studio provides tools you can use for managing your Web application project and for the creation of HTML, Java, and JSPs including graphics and database access. This is not an AS/400 product, but is available from the IBM Software Group. 2 Web Enabling AS/400 Applications with IBM WebSphere Studio

13 The following tools are included in WebSphere Studio Version 3.0: Studio WorkBench Studio Wizards Page Designer Applet Designer The following components are optional with WebSphere Studio Version 3.0: NetObjects Script Builder 3.01 VisualAge for Java 3.0 Professional Edition Remote Debugger 1.3 WebSphere Performance Pack WebSphere Performance Pack is a set of tools for caching, load balancing, and Web site replication. This is not an AS/400 product, but is available from the IBM Software Group. It comes in two versions. The first version is Cache Manager. It provides a proxy caching capability. The HTTP Server for AS/400 Web server already has caching proxy built into it. This is an enhancement over that. It uses more sophisticated algorithms and has some additional features. It is basically a Web server that acts as a caching proxy and does that very well. It also has a built-in PICS filtering platform, called Platform for Internet Content Specifications. This is a self-rating system. You can put information on your Web page that basically rates the contents of the Web page for violence, nudity, and so on. In the caching proxy, you can filter out those types of sites. Anybody using the caching proxy to access the Internet will never see the filtered content in their browser. This is especially useful in an educational environment where you are trying to screen out that type of information from students. Performance Pack Cache Manager running on the AS/400 system is planned to be available during the first half of Current plans are that it will be a separately priced offering on the AS/400 system. Performance Pack Cache Manager support is currently available on other operating systems. Availability Services provides the network dispatching capability or load balancing capability. This is needed when you want scalability or high availability services, for example, if you want multiple AS/400 systems to serve requests. Perhaps you have one Web address, but need more than one server to serve the requests to deliver adequate response time. You need multiple machines to look like one machine. Usually, a load balancer does that. All the requests come into the load balancer and are forwarded to the different Web server machines based on their capability of handling the requests. The load balancing software does not run on the AS/400 system. It actually runs on an external box including an IBM 2216 Router, AIX, SUN, or Windows NT box. It is a front end to multiple systems, including multiple AS/400 systems. This provides for scalability and high availability. Introduction to the IBM WebSphere family 3

14 1.4 WebSphere Site Analyzer The WebSphere Site Analyzer tools provide site administration and analysis tools that can be used to administer and manage the usage of a Web site. The collected statistics reside on the server, for example an AS/400 system. This data is downloaded to a Windows-based workstation with the site analysis tools installed. The tools perform the analysis and have graphical display functions to display the results. This is not an AS/400 product, but is available from the IBM Software Group. The Site Analyzer Tools include such functions as: An administration site visualizer A report generator and builder A content analyzer that scans the Web site and identifies such items as duplicates, unavailable resources, and content with excessive size A usage analyzer that scans the Web logs for hits, requests, paths, agents, and so on (analysis can be scheduled and results placed in a database) 1.5 Putting it all together Figure 1 shows how the family of WebSphere products fit together. WebSphere Studio Workbench Wizards Content Authoring Site Development Content Management VisualAge Application Programming Component Development Team Development Standard Edition Database Connection Manager Java Servlet Runtime and Services Caching Load Balancing Advanced Edition Clustering and scaling Enterprise Java Server (EJS) Database Connection Manager Java Servlet Runtime and Services Websphere Performance Pack Http Server Enterprise Edition Composed Business Components Transaction application environment CICS Encina Clustering and scaling EJS/EJB Database Connection Manager Java Servlet Runtime and Services Filtering Distributed files NT AIX Solaris OS/400 S/390 Tivoli Build Run Manage Figure 1. The WebSphere product family Note the following points in regard to Figure 1: WebSphere Studio and VisualAge for Java are used to build the applications. WebSphere Application Server is used to run the applications. It works in conjunction with the HTTP Server. 4 Web Enabling AS/400 Applications with IBM WebSphere Studio

15 WebSphere Performance pack is used for caching, load balancing, and Web site replication. Tivoli is used for change management. To find more information about the WebSphere family of products, refer to the Web site: For the latest information on WebSphere of the AS/400 system, go to the Web site at: Introduction to the IBM WebSphere family 5

16 6 Web Enabling AS/400 Applications with IBM WebSphere Studio

17 Chapter 2. Installation and configuration This chapter covers the installation and configuration of the environment required to run the servlets and JavaServer Pages discussed in this redbook. This includes the IBM HTTP Server for AS/400 and the IBM WebSphere Application Server (WAS). In this redbook, all references to WebSphere without other designation should be interpreted as references to IBM WebSphere Application Server for AS/400, Standard Edition, Version 2.0. Installing and configuring the WebSphere Application Server on the AS/400 system should take a minimal amount of time and effort. Before you begin, make sure that you have met the AS/400 software prerequisites. Refer to the ReadMe file available on the redbooks Web site ( formore information about minimum software requirements. For download information, refer to Appendix A, Example programs on page Introduction to WebSphere Application Server for AS/400 The IBM WebSphere Application Server is a Java servlet-based Web application server that helps you deploy and manage Web applications on the AS/400 system. On the AS/400 system, the WebSphere Application Server works in conjunction with the IBM HTTP Server for AS/400. There are some basic concepts that you must understand before you use the IBM WebSphere Application Server. For example, you should understand how to configure the HTTP server, and start or stop the HTTP server. The WebSphere Application Server for AS/400 is invoked through a server API program on the AS/400 system. As a server API program, Java servlet requests run under the main HTTP server job. Therefore, the request by default will run under the QTMHHTTP user profile. The HTTP server has an *ADMIN server instance that provides the administration and configuration graphical user interface (GUI) to manipulate the HTTP configuration. You use this GUI to enable Java servlet and JSP support. Today, the only Web server that supports the WebSphere Application Server on the AS/400 system is the IBM HTTP Server for AS/ Installation considerations The IBM WebSphere Application Server for AS/400 software that you need comes standard with OS/400, but is optionally installed. For OS/400 V4R4, the following software should be installed on your system: Copyright IBM Corp

18 JDK support For OS/400 V4R4, the AS/400 Developer Kit for Java (5769-JV1) supports multiple versions of the Java Development Kit. The versions supported are JDK 1.1.6, JDK1.1.7, and JDK 1.2. The WebSphere Application Server for AS/400 requires JDK or JDK to be installed. At the time this redbook was written, it did not support JDK 1.2. IBM OS/400 (5769-SS1) AS/400 Developer Kit for Java (5769-JV1) IBM HTTP Server for AS/400 (5769-DG1) IBM WebSphere Application Server for AS/400 (5769-AS1) Installing IBM WebSphere Application Server (V4R4) The IBM WebSphere Application Server Standard Edition Version 1.1 for AS/400 support is provided by installing the 5769-AS1 product (already pre-loaded on your system) on your AS/400 system. The AS/400 version has the same installation structure as other platforms. The only difference is the installation root directory. On the AS/400 system, it is installed in the Integrated File System (IFS). The installation root directory is /QIBM/ProdData/IBMWebAS/. The WebSphere Application Server PTFs are the latest that are available. The other PTFs that impact WebSphere may have been superseded by different PTFs. You should always load the latest PTFs. You can obtain this list of PTFs from the WebSphere Application Server Group PTF SF The group PTF is normally refreshed every month. The group PTF number does not change but is reused and updated with any additional WebSphere PTFs. It also contains the latest HTTP Server, database, and Java group PTFs. At the time of writing this redbook, the current version of the WepSphere group PTF (SF99027) upgraded the WebSphere Application Server to Version 2.02 for V4R4. The group PTF status can be displayed on the AS/400 system by running the following command: DSPDTAARA QAPPSVR/SF99027 Version 2.02 is installed if the display shows either of the following messages: Group PTF#: SF V4R4M0 09/01/1999 Group PTF#: SF V4R4 Version 1.1 is installed, if the display shows: Group PTF#: SF V4R4M0 06/29/ Installing IBM WebSphere Application Server (V4R3) This redbook was written using WebSphere Application Server 2.02 installed on an AS/400 system at release level V4R4. It is possible to run the WebSphere Application Server on a V4R3 system. At the time of writing this redbook, only WebSphere Application Server 1.1 was supported for V4R3. All the redbook examples, application design, testing, and configuration were done using V4R4 and WebSphere Application Server No testing was done on V4R3. 8 Web Enabling AS/400 Applications with IBM WebSphere Studio

19 The IBM WebSphere Application Server Standard Edition Version 1.1 is packaged as part of the IBM HTTP server for AS/400 (5769-DG1) in V4R3. It is a no charge, optionally installable licensed program product. WebSphere Application Server Group PTF SF99025 must be applied Considerations when upgrading from V4R3 to V4R4 In V4R4, the WebSphere Application Server for AS/400 is a separate product. There is a new product library for its program objects. The new library is named QAPPSVR. It is named QHTTPSVR for V4R3. This change must be reflected in the HTTP configuration when migrating from V4R3 to V4R4. You can use the *ADMIN HTTP Server GUI to re-enable the Java servlet to automatically get the correct directives for your WebSphere instance. In V4R4, due to the support of multiple JDKs support on the AS/400 system, the ncf.jvm.classpath no longer contains the system classpath. The shipped version of the jvm.properties file contains only the classpath for the WebSphere objects. Also, the following flag has been set to true by default: ncf.jvm.use.system.classpath=true If you migrate your jvm.properties from your V4R3 system, we recommend that you change the flag to true, and remove the old system classpath information about the JDK from the ncf.jvm.classpath setting. 2.3 Configuring the WebSphere Application Server for AS/400 The objective of this section is to successfully configure the WebSphere Application Server on the AS/400 system. This involves: Creating a new instance of the HTTP server Enabling servlets and JavaServer Pages for this instance Configuring the WebSphere Application Server The following steps take you through the complete configuration of the WebSphere Application Server environment: 1. Make sure that the HTTP server ADMIN instance is up and running. a. To check it, type WRKACTJOB on the AS/400 command line. Verify whether the ADMIN instance is running in the QHTTPSVR subsystem. If the ADMIN instance is not running, follow the next step. Otherwise, proceed to step 2. b. From the AS/400 command line, type: STRTCPSVR SERVER(*HTTP) HTTPSVR(ADMIN) Or, perform the task in step c. c. Open Operations Navigator by double-clicking on the icon on your desktop. Make a connection to the AS/400 system to which you wish to configure the WebSphere Application Server. The Operation Navigator window appears as shown in Figure 2 on page 10. Installation and configuration 9

20 Figure 2. AS/400 Operation Navigator window d. Click on the plus sign (+) next to the system icon on the left-hand side of the screen. Then, click Network->Server. Double-click the TCP/IP icon to open it. Select HTTP Administration. Right-click, and select Start from the pop-up menu. 2. Access the HTTP ADMIN server. This is a special server instance that is capable of allowing administrators to modify server configuration and start, stop, and restart instances of the HTTP server remotely using a Web browser. The ADMIN server usually runs on port Open a Web browser, and enter the URL (hostname is the name of your AS/400 system). 3. Enter your AS/400 login and password information when prompted. You now see the AS/400 Tasks display that appears as shown in Figure 3. Figure 3. AS/400 Tasks page 10 Web Enabling AS/400 Applications with IBM WebSphere Studio

21 4. Click IBM HTTP Server for AS/400, and click Configuration and Administration. 5. To create a configuration for your new server instance, click Configurations, and then click Create configuration. The Create Configuration page appears as shown in Figure 4. Figure 4. Configuration and Administration page 6. The right panel prompts you for a configuration name. This can be anything. Enter ABCCONF as the name. You can base your configuration file on an existing configuration file. In this case, select Create empty configuration, and click Apply. 7. Make sure the name of your configuration is in the drop-down box at the left, and click Basic. The Basic Configuration and Administration page appears as shown in Figure 5 on page 12. Installation and configuration 11

22 Figure 5. Configuration and Administration page: Basic 8. Enter 80 for the port number. This is the default port number for the HTTP server instance. If you change this, use a port number greater than Make sure that the port you use is not already being used. To check the port, type NETSTAT on the AS/400 command line, and select option In the Host Name box, enter the name of the AS/400 system. If you do not enter this value, a default value is set. This value is defaulted to the value set using the Configure TCP (CFGTCP) command option 12. Click Apply. 10.Enable the HTTP methods required, as well as server-side includes. Click on Request Processing and then Methods. The Methods Configuration and Administration page appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

23 Figure 6. Configuration and Administration page: Methods 11.Select the boxes for HEAD, GET, and POST. Selecting TRACE is optional. Click Apply. 12.To enable Java servlets, click Java Servlets. The Java Servlets Configuration and Administration page appears as shown in Figure 7 on page 14. Installation and configuration 13

24 Figure 7. Configuration and Administration page: Java Servlets 13.Select both check boxes that appear on this page. This allows you to use Java servlets and JavaServer Pages. Click Apply. 14.The following step is required only if your AS/400 system is at the V4R3 level. Otherwise, go to step 15. One of the key configuration files for the WebSphere Application Server Version 1.1 is the jvm.properties file, which resides in the following IFS directory /QIBM/ProdData/IBMWebAS/properties/server/servlet/servletservice/. Within the jvm.properties file, one of the attributes tells the WebSphere Application Server which HTTP configuration file is being used to run WebSphere. That information needs to be updated to point to the configuration file you configured. The shipped default configuration file is CONFIG. An entry in the properties file using CONFIG looks like this example: #ncf.native.httpd.cnf.path=c:\winnt\httpd.cnf ncf.native.httpd.cnf.path=/qsys.lib/qusrsys.lib/qatmhttpc.file/config.mbr In this case, use an ASCII-based text editor to change the line to point to the configuration file ABCCONF.MBR instead of CONFIG.MBR. 15.Create a new instance of the HTTP server that uses the configuration file that we just created. From the HTTP Server Configuration and Administration page, click Create server instance under Server Instances. TheHTTP Create server instance page appears as in shown Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

25 Figure 8. Configuration and Administration page: Create server instance 16.Enter ABCSERVER as the name of the instance. You should use a meaningful name. You may want to use the same name as you did for the configuration file. 17.Select your configuration file, ABCCONF, from the drop-down list. 18.Click Create to create the instance. 19.Directives are added to the HTTP configuration file as a result of the configuration work that we did. This example shows the directives as they appear for a WebSphere Standard Edition 1.1 configuration. This information is stored in file QUSRSYS/QATMHTTPC. The following directives are added to the HTTP configuration file: # Enable WebSphere support Service /servlet/* /QSYS.LIB/QHTTPSVR.LIB/QZHJSVLT.SRVPGM:AdapterService* Service /*.jsp /QSYS.LIB/QHTTPSVR.LIB/QZHJSVLT.SRVPGM:AdapterService* ServerInit /QSYS.LIB/QHTTPSVR.LIB/QZHJSVLT.SRVPGM:AdapterInit /QIBM/ProdData/IBMWebAS/properties/server/servlet/servletservice/jvm.properties ServerTerm /QSYS.LIB/QHTTPSVR.LIB/QZHJSVLT.SRVPGM:AdapterExit Pass /IBMWebAS/samples/* /QIBM/ProdData/IBMWebAS/samples/* Pass /IBMWebAS/doc/* /QIBM/ProdData/IBMWebAS/doc/* Pass /IBMWebAS/system/admin/* /QIBM/ProdData/IBMWebAS/system/admin/* Pass /IBMWebAS/* /QIBM/ProdData/IBMWebAS/web/* # end - WebSphere support The following directives appear for a WebSphere Standard Edition 2.02 configuration. The Information is also stored in the file QUSRSYS/QATMHTTPC. # Enable WebSphere support Service /servlet/* /QSYS.LIB/QAPPSVR.LIB/QZHJSVLT.SRVPGM:AdapterService Service /*.jsp /QSYS.LIB/QAPPSVR.LIB/QZHJSVLT.SRVPGM:AdapterService ServerInit /QSYS.LIB/QAPPSVR.LIB/QZHJSVLT.SRVPGM:AdapterInit /QIBM/ProdData/IBMWebAS/properties/bootstrap.properties ServerTerm /QSYS.LIB/QAPPSVR.LIB/QZHJSVLT.SRVPGM:AdapterExit Installation and configuration 15

26 Pass /IBMWebAS/samples/* /QIBM/ProdData/IBMWebAS/samples/* Pass /IBMWebAS/* /QIBM/ProdData/IBMWebAS/web/* # end - WebSphere support In Version 2.02, the key properties file is a new file called bootstrap.properties. The jvm.properties file in version 1.1 is no longer used. Most of the attributes in the jvm.properties map back into the bootstrap.properties file. There is no reference back to the HTTP configuration file in the bootstrap.properties file. You do not need to update the bootstrap.properties file for your particular server instance Adding directives Rather than using the default directories, you may want to use your own directories to serve HTML pages, JSPs, applets, and images. In this case, you must add PASS directives to the HTTP configuration to allow the HTTP server to serve the files from your directories. To do this, use the HTTP Server Configuration and Administration page Adding directives for the ABC Company sample project Section 4.3.1, Publishing to the AS/400 system on page 125, explains how to publish the WebSphere Studio sample project (ABC Company Web site) to the AS/400 system. In order for the WebSphere Studio application to select the correct AS/400 file path, which contains the application files, you need to add directives to your HTTP configuration. Perform the following tasks to add directives to the ABCCONF configuration: 1. Open a Web browser, and enter the URL (hostname is the name of your AS/400 system). 2. Enter your AS/400 login and password information when prompted. 3. Click IBM HTTP Server for AS/400, and then click Configuration and Administration. 4. To add directives to the ABCSERVER instance, click Requesting Processing, and then Request routing. The Configuration and Administration page appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

27 Figure 9. Configuration and Administration page: Adding directives 5. To add the required directives, enter the following information in the corresponding fields: Action: Pass URL template: /* Replacement file path: /qibm/proddata/ibmwebas/* Note Ensure that the Index number matches the same index number in the last row. Verify that the Insert after radio button is selected. 6. Click the Apply button. 7. Click Display Configuration to verify that the Pass directives you add are placed after the Service directives as shown in Figure 10 on page 18. If they are in front of the Service directives, your servlets and JSPs may not be passed to the WebSphere service programs. Installation and configuration 17

28 Figure 10. Configuration and Administration page: Display configuration Testing your HTTP server configuration To test the HTTP configuration (ABCCONF) that you just created, perform the following tasks: 1. Start the server instance. On the IBM HTTP Server Configuration and Administration page, click Server Instances->Work with server instance. The Work with server instances page appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

29 Figure 11. Configuration and Administration page: Server Instances 2. Select the server instance ABCSERVER from the drop-down list, and click the Start button. 3. To test if the configuration is successful, start a browser session on your client. Enter the URL: Replace hostname with the name of your AS/400 system and port with the TCP/IP port that you are using. As shown in Figure 12, if Hello World is displayed in your browser, the WebSphere Application Server is set up and ready to go. Figure 12. HelloWorldServlet Installation and configuration 19

30 To run your own servlets, place them in the \QIBM\ProdData\IBMWebAS\servlets directory in the AS/400 system IFS. You can place your HTML and JSP files in the \QIBM\ProdData\IBMWebAS directory Configuring the AS/400 Toolbox for Java The WebSphere Studio Wizards run on a client platform. To allow the WebSphere Studio Wizards to access AS/400 resources, you need to set the classpath in your PC to point to AS/400 Toolbox for Java jt400.jar file. It is found in the /QIBM/ProdData/HTTP/Public/jt400/lib/ directory path in the AS/400 IFS. Either copy the jt400.jar file to your PC, or map a network drive to the AS/400 system to set the classpath Troubleshooting the WebSphere Application Server To learn more about the WebSphere Application Server, servlets, JSPs, and XML, refer to the documentation and FAQs at: Installation and configuration on other platforms For installation and configuration of the WebSphere Application Server on other platforms, refer to the redbook WebSphere Application Servers: Standard and Advanced Editions, SG WebSphere Application Server Administration To start the WebSphere Application Server Administration support, enter this URL from your Web browser: The default port is 9090 (use port 9527 for other platforms). If you configured multiple instances, use the administration port configured for the new instance. The Administration support enables you to: Customize settings for a variety of Application Server components Configure servlets and set up aliasing and filtering Establish and maintain security Collect data and monitor the Application Server Test the administration port to make sure the WebSphere Application Server Administration support is running on the port you specified. As shown in Figure 13, if the login page for the WebSphere Administration GUI is displayed, the administration support for your new instance is working. 20 Web Enabling AS/400 Applications with IBM WebSphere Studio

31 Figure 13. Administration Log in page Installation and configuration 21

32 22 Web Enabling AS/400 Applications with IBM WebSphere Studio

33 Chapter 3. WebSphere Studio tools IBM WebSphere Studio is a suite of tools for the development of Web applications. In this redbook, we refer to it simply as Studio. It is optimized specifically for building WebSphere Application Server applications, but you can also use many of the Studio tools for development of applications for other Web servers or Web application servers. You run the WebSphere Studio development tools on a Windows workstation, but you can deploy the resulting application to an AS/400 system running IBM WebSphere Application Server. WebSphere Studio provides tools you can use for managing your Web application project and for the creation of HTML, Java servlets, and JSPs. Studio delivers a complete set of Web development tools with clear advantages of performance, portability, and lower maintenance over other approaches such as Common Gateway Interface (CGI) and Active Server Pages (ASP). Studio combines graphical development wizards with tools for Web site design and Java development, with features including: A workbench environment that lets Web development teams organize and manage Web development projects. This environment can be extended with source control management (SCM) tools. Of particular interest is the ability to use Studio with the Lotus Domino Web Content Library, which, in addition to version support, allows integration with Domino workflow. An industry-leading, easy-to-use, integrated visual page designer for JSPs, HTML and Dynamic HTML (DHTML) that accelerates Web page development. An integrated remote debugger for easy remote debug of server-side scripts and logic (including JSP components, servlets, JavaBean components, and more). The remote debugger requires the Standard or Advanced edition of IBM WebSphere Application Server. Integrated wizards to help developers create dynamic interactive Web pages. Wizards generate JSPs, JavaBeans, SQL statements, and servlets. Tighter integration between IBM VisualAge for Java Professional Edition, V3.0 and Studio, making it easy for teams to communicate and work together to develop Web-based, e-business applications. An integrated applet designer based on the NetObjects BeanBuilder technology. NetObjects ScriptBuilder allows for easier script editing of Extensible Markup Language (XML) and Wireless Markup Language (WML). An integrated Web art designer that lets you create masthead images, buttons, and other graphics. An integrated animated GIF designer that makes it easier to create animated GIFs. A development copy of IBM WebSphere Application Server for building and testing Web applications. The following tools are included in WebSphere Studio Version 3.0: Studio WorkBench Studio Wizards Copyright IBM Corp

34 Page Designer Applet Designer The following components are optional with WebSphere Studio Version 3.0: NetObjects Script Builder 3.01 VisualAge for Java 3.0 Professional Edition Remote Debugger Minimum hardware requirements The minimum hardware requirements are: Intel Pentium class PC 180 MB of free disk space for installation CD-ROM drive 32 MB of memory (minimum) VGA, or better video adapter, configured for at least 256 colors Minimum software requirements The minimum software requirements are: Windows 95, Windows 98 or Windows NT, Version 4.0 with Service Pack 3 Microsoft Internet Explorer Version 4.0 (or higher) or Netscape Navigator Version 4.5 (or higher) 3.1 Studio WorkBench The Studio Workbench is the integration point for the tools suite. In this redbook, we refer to it simply as the Workbench or the Studio. You can create, open, and edit all types of files from the WorkBench. You can launch Page Designer and other tools in the suite against a particular file directly from the Workbench. You can also register other tools for editing a particular file type from the Workbench. The Workbench also helps manage and maintain your Web site applications and files. You use projects and folders in the Workbench to group and organize files. You can create, delete, copy, and move files from the Workbench. The Workbench provides basic check-in and check-out capabilities to control file management in a team environment and integrates with leading source control systems. The Workbench also provides you a central point for managing the publication of your finished Web site. You define properties of the server to which you want to publish. Workbench then automatically manages the distribution of all individual files within a project to the selected server Creating a new project To work on WebSphere Studio, you first need to create a project within WebSphere Studio. To do so, follow these steps: 1. Start WebSphere Studio if it is not already started. When Studio starts, you are immediately prompted to create a new project or open an existing one (Figure 14). 24 Web Enabling AS/400 Applications with IBM WebSphere Studio

35 Figure 14. Studio Workbench: Welcome to IBM WebSphere Studio 2. Select the Create a new project radio button, and click OK. You are then prompted for the necessary project information: a. Type DemoCompany as the name of the project. b. Enter x:\democompany as the project folder. Replace x with the workstation drive on which you want to create the project. c. Leave project template as <none>. d. Click OK. A new project is created and you go to the Studio Workbench. In this chapter, we work with the DemoCompany project for demonstration purposes. At this point, your window should appear as shown in Figure 15. Figure 15. Studio Workbench: The workbench with the new project WebSphere Studio tools 25

36 3. Notice that the workbench is divided into two frames. The left-hand frame is always the File view. The right-hand frame is either the Publishing view or the Relations view. 4. The File view represents the physical organization of your Web site source files. In the Studio main window, the File view is in the left pane, and it is always open. It is a hierarchical tree of the selected project and its folders. This view represents the directory structure of a project as it exists in the local file system or shared file system. The highest level in the tree is the project. A project can contain files and folders. Folders can contain files and other folders. This lets you organize your files in any way that you like, making it easy to manage all the files for an entire Web site as a unit. 5. In the Studio Workbench, you can see the following options: Menu bar: Provides access to all the available functions. If you can't find a function in a pop-up menu, look for it in the menu bar. Main tool bar: Gives you quick access to common functions (New, Open, Print, Cut, Copy, and Paste) and Studio-specific functions such as to Insert Folder, Insert File, Publish, Compile, and Run the selected wizard. It also lets you toggle the between the Relations view and the Publishing view and synchronize them with the File view. File filter tool bar: Lets you filter files in all the views by their file types. For example, you can use the file filters to hide image, audio, and executable files. Link filter tool bar: Lets you filter the files in the Relations view by the type of links that they have. With large Web sites, this can help you locate specific areas of interest, such as outside links or broken links. Status bar: As you move your mouse over objects in a view, the status bar provides details, such as the path or type of link and the current publishing stage. The status bar has a fixed position at the bottom of the main window. 6. Studio Workbench has visual cues, file filters, and link filters. Visual cues: Studio provides several visual cues so you can determine the state of a file at a glance. Look for these indicators next to a files icon in any of the Studio views: The file cannot be published. A file you checked out for editing. A file someone else checked out for editing. 26 Web Enabling AS/400 Applications with IBM WebSphere Studio

37 A file that has been published. A file that has been modified since the last time it was published. Link types and link filters: Your project files can contain many types of links. Links to specific places in the file Links to embedded images in the same file Links to other files in the same project Links to files on other Web sites, on your Web servers, or anywhere in the world Studio recognizes these standard hypertext links, manages them for you, and lets you know when they are broken. It also recognizes the links to files that are specified as parameters in Java servlets, CGI, and Perl scripts. The Relations view uses different images to represent each of these link types. It is common for the relationship between two files to be represented by more than one type of link. For example, the relationship between an.html file and a.gif image is represented by both an inside link (both files are in the project) and an embedded link. These icons define the links: A link to another file in the same project. A link to a file, such as an image or frameset, that is rendered on the same page. Alinktoafileoutsidetheproject. A link from a file to another file in the project with an incorrect path. A link to a file that cannot be verified using the HTTP protocol. A link that represents a user-defined relationship. A link from a publishable file to a source file that is used to create it. WebSphere Studio tools 27

38 A link to a file specified as a parameter by a user-defined rule. A link to a specific point within the same file. A link to the same file that contains the link. 3.2 Studio Wizards WebSphere Studio has several wizards that provide a quick and easy way to generate servlets, JSPs, and JavaBeans. Servlets and JavaBeans Servlets and JavaBeans are two types of Java classes used in the WebSphere Studio Wizards. Servlets are server-side Java programs that use the Java servlet Application Programming Interface (API) and its associated classes and methods. They are similar to applets, but they run on a server rather than a client platform. Servlets run on a Java-enabled Web server, such as the WebSphere Application Server, and extend the server's capabilities. When a browser sends a request to the server, the server can send the request information to a servlet and have the servlet construct the response that is sent back to the browser. JavaBeans are Java programs that follow the JavaBean specification from Sun Microsystems. By design, they are reusable components that can be called from other Java programs. To accomplish this, JavaBeans have standard ways of implementing their properties, methods, and events, so they can be examined and manipulated programmatically. JavaServer Pages (JSP files) JSP files, or JavaServer Pages, are the way the WebSphere Studio implements dynamic page content. JSPs make it possible to embed Java right into Web pages. One of the advantages of JSP technology is that it enables you to effectively separate the HTML coding from the business logic in your Web pages. You use JSPs to access reusable components, such as servlets, JavaBeans, and Java-based Web applications. JSPs also support embedding inline Java code within Web pages. JSPs are similar to Microsoft's Active Server Pages (ASP). JSP files allow the Application Server to dynamically add content to HTML pages before they are sent to a requesting browser. The dynamic content can come from any available databases and file systems to provide Web visitors with the most timely and accurate data. JSP support for JavaBeans enables you to reuse components across your Web site. The JSP files created by the Studio Wizards contain the following HTML tags and JSP tags defined by the JSP specification: <BEAN> to access a JavaBean when the page is processed <INSERT> to embed variables in the page 28 Web Enabling AS/400 Applications with IBM WebSphere Studio

39 HTML to format the variable data <REPEAT> to repeat a block of HTML tagging that contains <INSERT> tags and the HTML formatting tags When you install the Application Server on a Web server, the Web server's configuration is set to pass HTTP requests for JSP files (files with the extension.jsp) to the Application Server. The Application Server configuration is set to pass JSP files to its JSP processor (pagecompile). The JSP processor creates and compiles a servlet from each JSP file. The processor produces two files for each JSP file:.java file: Contains the Java language code for the servlet.class file: The compiled servlet When the Application Server processes a JSP file, it does the following tasks: Parses the JSP file Strips out the Java code and creates a valid.java file (servlet) Compiles the.java file to produce a.class file Executes the.class file Reads in the original JSP file Write Puts the resulting data into the output page (replacing the special tags) Writes Java and HTML output to the browser The generated.java and.class files are stored in the Web server servlets\pagecompile directory. A timestamp is kept inside the generated.java file. It is only recreated and recompiled if the.jsp file changes Importing an existing Web site An import wizard is provided from within Studio Workbench. It copies existing Web site files from their server on the Web into a WebSphere Studio project. This is useful if you want to start your development from an existing Web site. Importing uses either the HTTP or FTP protocol to bring the files from their existing file location into the Studio project. To start the Import wizard, follow these steps: 1. Select File->Import. The Import Wizard, as shown in Figure 16 on page 30 is displayed. It prompts you for the source URL. 2. Enter the URL from where you want to import Web site files into the WebSphere Studio. You can now use the Studio tools to develop a Web site based on the imported site. WebSphere Studio tools 29

40 Figure 16. Studio Workbench: Import Wizard Refer to Chapter 4, Restoring the ABC Company Web site sample project on page 121, for a complete example of importing an existing Web site Database Wizard Several wizards are provided for you from within the Studio Workbench for quickly and easily adding dynamic content from a relational database to your Web pages. The wizards generate the server side Java and SQL code necessary for retrieving and updating database information. With these wizards, you can develop a Web application that does a simple database query without writing any Java or SQL code. You can use these wizards to build dynamic Web pages that access DB2 for AS/400 with either the AS/400 Developer Kit for Java JDBC driver (the native JDBC driver) or the AS/400 Toolbox for Java JDBC driver (the Toolbox JDBC driver). Since the WebSphere Studio Workbench runs on a workstation, you will need to use the Toolbox JDBC driver during your initial development. You can then edit the wizard generated source code to use the Native JDBC driver when you are ready to deploy your servlet to the AS/400 system. The Studio Wizards recognize any JDBC drivers found in your workstation classpath and make them selectable by name. Make sure to add the Toolbox JDBC driver to your workstation classpath. See 2.3.3, Configuring the AS/400 Toolbox for Java on page 20, for information about adding drivers in your workstation classpath. The following Studio Wizards are available: SQL Wizard Database Wizard JavaBean Wizard In this section, we use SQL, Data Access, and JavaBean wizards to create, insert, update, and delete records in an AS/400 database Creating an SQL SELECT statement The Studio provides the SQL Wizard, which allows you to interact with the database metadata to build SQL statements. These statements are stored in a file with an.sql extension. The Database Wizard uses the created.sql file to 30 Web Enabling AS/400 Applications with IBM WebSphere Studio

41 generate the necessary JavaBeans, servlets, and XML files to execute the SQL statement. In this section, we create a SELECT statement to view an AS/400 database table. We use the Item table, which is found in AS/400 APILIB database. Refer to Chapter 5, Order Entry application on page 137, for descriptions of the database tables we use in this chapter. To successfully do these steps, you must: Restore APILIB to your AS/400 system. See Appendix A, Example programs on page 405, for information about how to obtain the APILIB database. Make the AS/400 Toolbox for Java.zip or.jar file is available through your workstation classpath. To use WebSphere Studio to create a query of the AS/400 Item Table, follow these steps: 1. Select the DemoCompany project folder. 2. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. The Welcome window appears as shown in Figure 17. Figure 17. Studio SQL Wizard 3. Complete the following steps: a. Enter ItemSearch as the name of the query. The wizard adds an.sql file to your project. b. Click Next. The Logon window appears shown as shown in Figure 18 on page 32. WebSphere Studio tools 31

42 Figure 18. SQL Select: Logon 4. Complete the following steps: a. Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://sysname Userid: USERID Password: PASSWORD Driver: AS/400 Toolbox for Java Replace sysname with the name of your AS/400 system. Case is important for the Userid and Password. Both should be in uppercase. b. Click Connect to connect to the specified database. c. After you successfully connect, click the Next button to go to the next tab. 5. The Schema(s) to View window appears as shown in Figure 19. If the Schema(s) to View window does not appear, click the View schema(s) button. Figure 19. SQL Select: View schema(s) 32 Web Enabling AS/400 Applications with IBM WebSphere Studio

43 6. Complete the following steps: a. In the Schema(s) to View window, find the Library with which you want to work, which, in this case, is APILIB. Click on the library to select it, and click the Add>> button. b. If there are schema(s) in the Selected Schema window that you want to remove, select the schema, and click the <<Remove button. c. Click the OK button to return to the Tables window. The Tables window appears as shown in Figure 20. Figure 20. SQL Select: Table window 7. Complete the following steps: a. Select the Select radio button under Statement type. b. Select the APILIB.ITEM table from the list of tables shown. c. Click Next. The Join window appears as shown in Figure 21 on page 34. WebSphere Studio tools 33

44 Figure 21. SQL Select: Join window 8. Click the Next button. The Columns window appears as shown in Figure 22. Figure 22. SQL Select: Columns window 9. Complete the following steps: a. Verify whether the correct table name is selected in the Selected table(s) drop-down list. b. Select the required columns, and click Add>> buttontomovethese columns over to Columns to include. Refer to Figure 22 as a guide. c. When the SQL query is used, data from the selected columns is retrieved by the SELECT statement. After making your column choices, you can 34 Web Enabling AS/400 Applications with IBM WebSphere Studio

45 change the order in which they appear by selecting the column name and using the Move Up and Move Down buttons. d. Click Next. The Condition 1 window appears as shown in Figure 23. Figure 23. SQL Select: Condition window 10.Complete the following steps: a. Verify whether the correct table name is selected in the Selected table(s) drop-down list. b. Select a column name on which you wish to put a condition, which is IID (Item Number) in this case. c. Select the condition from the Operator list box. In this case, select is after or equal to. d. Click the Values field, and then click the Parameter button. Enter Low for the field in the parameter dialog. e. Click the OK button to return to the Condition 1 tab. f. Click the Find on another column button. The Condition 2 window appears as shown in Figure 24 on page 36. WebSphere Studio tools 35

46 Figure 24. SQL Select: Condition window 11.Complete the following steps: a. Check if the correct table name is selected in the Selected table(s) drop-down list. b. Select the Find fewer rows (AND) radio button. c. Select the column name on which you want to put a condition, which is IID (Item Number) in this case. d. Select the condition from the Operator list box, is before or equal to, in this case. e. Click the Value field, and then click the Parameter button. Enter High for the field in the parameter dialog. f. Click the OK button to return to the Condition 2 tab. g. Click Next. The Sort window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

47 Figure 25. SQL Select: Sort window 12.Complete the following steps: a. Select a column name from the columns box, IID (Item ID) in this case. b. Select the order from the Sort order drop-down list. Select Ascending. c. Click the Add button. d. The selected column is used to sort the retrieved data. You can add more columns on which to sort. After you add the columns to the Columns to sort on box, you can change their order by using Move Up and Move Down buttons. e. Click Next. The SQL window appears as shown in Figure 26 on page 38. WebSphere Studio tools 37

48 Figure 26. SQL Select: Statement window 13.Complete the following steps: a. The SQL tab shows the completed SQL statement. You can copy the statement to the clipboard to use it in another application. b. You can test the SQL statement by clicking on the Run SQL button. Valid Item numbers are to c. Click Next. The Finish window appears as shown in Figure 27. Figure 27. SQL Select: Finish window 14.Click the Finish button. 38 Web Enabling AS/400 Applications with IBM WebSphere Studio

49 15.Check in the generated ItemSearch.sql file in the Studio Workbench Building the servlet using the SQL SELECT statement We use the Database Wizard to create a servlet, which uses the SQL statement that we created in the previous section. The Database Wizard helps you create Web applications that can query, insert, update, and delete relational data. When you start the Database Wizard, Studio assumes that the current project in the file view is where you want your database access files to go. The Database Wizard puts the.java,.class, and.servlet files it creates in the servlet folder, and the HTML and JSP files in whichever folder is current (selected) when you start the Database Wizard. Follow these steps: 1. Select the DemoCompany project from the Studio Workbench. 2. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. The Database Wizard window appears as shown in Figure 28. Figure 28. Studio Database Wizard 3. Complete the following steps: a. Select the appropriate SQL statement. Select \DemoCompany\ItemSearch.sql. b. Click Next. The Web Pages window appears as shown in Figure 29 on page 40. WebSphere Studio tools 39

50 Figure 29. Database Wizard: Web Page window 4. Complete the following steps: a. The Web pages window allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. i. Select the input page check box. ii. Select the output page check box. iii. Select the error page check box. b. Click Next. The Input Page window appears as shown in Figure 30. Figure 30. Database Wizard: Input Page window 40 Web Enabling AS/400 Applications with IBM WebSphere Studio

51 5. Complete the following steps: a. Select both the Low and High input parameters. b. To give the fields a more meaningful name, follow these steps: i. Select the parameter name check box. ii. Select the parameter line and then change the caption to some meaningful name by clicking the Change button and entering the text in the dialog. c. Click Next. The Results Page window appears as shown in Figure 31.. Figure 31. Database Wizard: Results Page window 6. Complete the following steps: a. Select the following items: APILIB_ITEM_IDATA APILIB_ITEM_IID APILIB_ITEM_INAME APILIB_ITEM_IPRICE b. If desired, change all of the captions to more meaningful names. Select the first row, and click Change. When prompted, enter the name. Follow this step to change the caption for all the fields. c. Ensure that the Table radio button is selected. d. Click Next. The Standard Error Page window appears as shown in Figure 32 on page 42. WebSphere Studio tools 41

52 Figure 32. Database Wizard: Standard Error Page window 7. Click Next. The Methods window appears as shown in Figure 33. Figure 33. Database Wizard: Methods window 8. Click Next. The Session window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

53 Figure 34. Database Wizard: Session window 9. Complete the following steps: a. Select the No radio button. b. Click Next. The Finish window appears as shown in Figure 35. Figure 35. Database Wizard: Finish window WebSphere Studio tools 43

54 10.Complete the following steps: a. Give a meaningful name to the generated source files. Click Rename and type ItemSearch in the Prefix dialog. Click OK. Note that all of the files now have the prefix of ItemSearch. b. Click the Finish button to generate the code. You should see the following files added to the DemoCompany project: ItemSearchInput.html ItemSearchResults.jsp ItemSearchError.jsp If you look inside the servlet->democompany folder, you also see that the following files have been created: ItemSearchDBBean.java ItemSearch.java ItemSearch.servlet ItemSearchDBBean.class ItemSearchDBBean.class 11.Check all of the generated files into Studio. Select the DemoCompany folder. Using the pop-up menu, select the Check In option. The files are already checked in if the Check In option is not available from the pop-up menu. Before you can view the Web site application, you must publish it Publishing the Web site To deploy an application developed using WebSphere Studio, you must publish it. You can publish your project files to your local workstation, to a shared file system, or to a remote system that you can access using FTP. These systems can hold test or live sites. You can publish entire projects, a part of a project, or just individual files. A publishing stage specifies the publishing Web server (or Web servers) and the folder structure of the files. To publish the Web site, you need to define at least one publishing stage with an accessible publishing server. By default, all WebSphere Studio projects have a Test and a Production publishing stage, and you can create and name your own custom stages. If you have an HTTP server running locally, the Test stage starts out with localhost as the default publishing server, and it has the same file and directory structure as the File view. In all other cases, you must add one or more publishing servers to the stage and configure their properties Setting up publishing stages In WebSphere Studio, a publishing stage is a model of the structure of your Web site that is used for publishing. A publishing stage specifies the publishing Web server (or Web servers) and the folder structure of the files. Having more than one publishing stage can be useful if you publish your Web sites to different Web servers at various stages of their design and development. For example, you may have a Web server inside the firewall that you use to review your work before it is complete, and another Web server outside a firewall where you publish your final Web site. 44 Web Enabling AS/400 Applications with IBM WebSphere Studio

55 Creating publishing stages WebSphere Studio comes with two publishing stages for you to use: Test and Production. If you have an HTTP server installed on your computer, WebSphere Studio detects this and creates a default server setting for your Test publishing stage that points to your local host ( Otherwise, WebSphere Studio uses the first server you define for a Test or Production stage as the default server for that stage in each project. You can change the default stage setting for both the Test and Production stages at any time. You can define and create other custom publishing stages as needed. When the publishing view is on, you can switch from one publishing stage to another: To change the default server for Test and Production publishing stages: 1. From the main menu, select Tools->Publishing. 2. Click the Advanced tab, and select a server from the list. To create a custom publishing stage: 1. Select Project->Custom Publishing Stages. 2. Enter the name, and click the Add button. To copy the files from one publishing stage to another: 1. Select Project->Copy Publishing Stages. 2. Select the From and To stages. Defining the default publishing server in a stage When you add a new server to a stage, you can make it the default publishing server. WebSphere Studio then uses this new default publishing server when determining the default publishing path of any new files you add to the project or any files that you move. The files that were on the other server (previously the default publishing server) are now considered to have customized publishing paths. If you want to move them to the new default publishing server, you can drag and drop them there, or you can change their default publishing path property. To add a server to a publishing stage: 1. Right-click on the stage icon. 2. Select Insert->Server from the menu, and then enter the server name. 3. After you add the server, define its properties. Note Notice that this server is added under the stage icon. Right-click on this server, and select Properties. The properties window appears, select Define Publishing Targets, and enter the path for the Web server and the WebSphere server. To change the default server: 1. Right-click on the stage icon. 2. Select Properties from the menu. 3. Click the Advanced tab, and select the server. WebSphere Studio tools 45

56 3.2.4 Publishing to the AS/400 system To publish the Web site to the AS/400 system, perform the following steps: 1. Map a network drive to the IFS of the AS/400 system. In this example, we map the I: drive to the root of the AS/400 IFS: \\youras400\root 2. Start WebSphere Studio, and open the DemoCompany project. 3. Select Project->Publishing Stage->Test. 4. Select the Publishing View by selecting View->Publishing. 5. Add the AS/400 server to the Test stage. Right-click the Test stage icon. Select Insert->Server from the menu as shown in Figure 36. Figure 36. Inserting a server in the Test publishing stage 6. Enter the server name, youras400, and the TCP/IP port on which you configured the WebSphere Application Server as illustrated in Figure 37. After you add the server, you need to define its properties. Figure 37. Inserting the AS/400 server in the Test publishing stage As shown in Figure 38, you now see the new server under the Test publishing stage. Figure 38. The Test publishing stage 7. To change the default server to your AS/400 server, right-click on the Test stage icon, and select Properties from the menu. Click the Advanced tab, and select the AS/400 server from the Default server drop-down list as illustrated in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

57 Figure 39. Changing the default server 8. Close the Test Properties dialog by clicking the OK button. 9. Update the publishing targets for the AS/400 server by right-clicking on the AS/400 server icon, and selecting Properties from the menu. When the Publishing Properties dialog appears, click the Define Publishing Targets button. When the publishing targets dialog appears as shown in Figure 40 on page 48, verify that the targets match as shown here: html I:\QIBM\ProdData\IBMWEBAS\ servlet I:\QIBM\ProdData\IBMWEBAS\servlets Here, I: is a network drive assigned to the root of the AS/400 Integrated File System (IFS). Publishing target You may want to publish your HTML files to a separate directory. For this, you have to create an HTML directory under the \QIBM\ProdData\ibmwebas\html directory, and then add a Pass directive in your HTTP configuration file. 10.If your targets do not match the description in step 9, click the Browse button to navigate through the file system to find the files. WebSphere Studio tools 47

58 Figure 40. AS/400 Publishing Targets 11.Close the Publishing Targets dialog by clicking the OK button. 12.Close the Publishing Properties dialog by clicking the OK button. 13.To set a default publishing target, select Tools->Publishing Options from the pull-down menu. Click the Advance tab. Select the AS/400 publishing target system from the Test drop-down list as illustrated in Figure 41. Figure 41. Setting the AS/400 server as the default publishing server 14.Close the Publishing Options dialog by clicking the OK button. 15.To move the files to the publishing stage, select the DemoCompany project. Then, select Edit->Set as Publishable->Yes from the pull-down menu to set the ABC Company files as publishable. This process moves all the project components under the Test->yourAS400 stage as illustrated in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

59 Figure 42. Setting the project files as publishable 16.From the publishing view, select the server Right-click to display the pop-up menu, and select Publish this server. 17.Several dialogs may appear. Select the default options on each. Simply click OK, Yes, oryes to All, ignoring the warnings. Publishing causes WebSphere Studio to copy all the files set as publishable to the publishing target (a Web servers directory structure). After this publishing process finishes, you receive a report as illustrated in Figure 43 on page 50. WebSphere Studio tools 49

60 Figure 43. Publishing a report for the Demo Company project 18.Browse through the report to ensure that no files were found with errors before attempting to proceed. In case errors were found, you need to correct them, and then repeat the steps in this section Previewing the Demo Company Web site Once you have published the Web site, you can preview it. Previewing Web sites The first time you call a generated Studio Wizards servlet, it will be slow. This is due to the fact that the JSP has to be compiled and the servlet has to connect to the database. Subsequent tries will be much faster. Perform the following steps to preview the Demo Company Web site: 1. Ensure that the WebSphere Application Server on AS/400 is up and running. 2. To test the publishing process, select the ItemSearchInput.html file from the publishing view to preview it. Then, right-click and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the Demo Company input page appears as in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

61 Figure 44. Input Search page on the browser 3. Enter the values for the search condition of the SQL statement. Valid values are to Click the Submit button to execute the query. The generated servlet shows the results that satisfy the query condition as shown in Figure 45. Figure 45. Result page on the browser A number of files are generated by the Database Wizard. Figure 46 on page 52 shows how they fit together. WebSphere Studio tools 51

62 ItemSearchDBBean Item 3 5 ItemSearchInput.html 1 2 ItemSearch.java servlet 4 ItemSearchResults.jsp 6 JSP ACTION="/servlet/DemoCompany.ItemSearch" Figure 46. Application flow To run the application, we enter the URL for the ItemSearch.html page. In this case, we enter: The following actions occur: 1. The HTML form is displayed in the browser. 2. The action of the Submit button executes the ItemSearch servlet. 3. The ItemSearch servlet instantiates ItemSearchDBBean, which executes the query. 4. The ItemSearch servlet calls the JSP named ItemSearchResults.jsp. 5. The ItemSearchResults JSP uses methods of the ItemSearchDBBean bean to retrieve the query results. 6. The JSP renders an HTML form that displays the query results More WebSphere Studio Wizard examples In this section, we show more examples using the Studio Wizards. These example are all similar, but they show examples of generating different SQL statements. We also show an example of the JavaBean Wizard. If you are comfortable with the Studio Wizards, you can skip to the Page Designer examples in 3.3, Page Designer on page Creating an SQL INSERT statement In this section, we create a simple INSERT statement to insert records in the Item database table. Follow this process: 1. Select the DemoCompany project. 2. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 52 Web Enabling AS/400 Applications with IBM WebSphere Studio

63 The Welcome window appears as shown in Figure 47. Figure 47. Studio SQL Wizard 3. Complete the following steps: a. Enter ItemInsert as the name of the query. The wizard adds an.sql file in your project. b. Click Next. The Logon window appears as shown in Figure 48. Figure 48. SQL Insert: Logon window 4. Complete the following steps: a. Enter the information the wizard needs to connect to the database, for example: WebSphere Studio tools 53

64 Database URL: jdbc:as400://sysname Userid: USERID Password: PASSWORD Driver: AS/400 Toolbox for Java Replace sysname with the name of your AS/400 system. Case is important for Userid and Password. Both should be in uppercase. b. Click Connect to connect to the specified database. c. Click Next. The Tables window appears as shown in Figure 49. Figure 49. SQL Insert: Tables window 5. Complete the following steps: a. Click Insert under Statement type. b. Select APILIB.ITEM from the list of tables shown. c. Click Next. The Insert window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

65 Figure 50. SQL Insert window 6. Complete the following steps: a. Select the columns that are to be part of the Insert statement by clicking in the value text field to enable the Parameter button. For each column, click the Parameter button to enter a parameter value, and then type the name of the parameter. b. Click Next. The SQL Statement window appears as shown in Figure 51. Figure 51. SQL Insert: Statement window WebSphere Studio tools 55

66 7. Complete the following steps: a. The SQL tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. b. Click Next. The Finish window appears as shown in Figure 52. Figure 52. SQL Insert: Finish window 8. Click Finish button. 9. Check in the generated ItemInsert.sql file in the Studio Workbench Building the servlet using the SQL INSERT statement We use the Database Wizard to create a servlet, which uses the SQL statement that we created in , Creating an SQL INSERT statement on page 52. The Database Wizard helps you create Web applications that can query, insert, update, and delete relational data. Follow these steps: 1. Select the DemoCompany project from the Studio Workbench. 2. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. The Database Wizard window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

67 Figure 53. Studio Database Wizard 3. Complete the following steps: a. Select the appropriate SQL statement \DemoCompany\ItemInsert.sql. b. Click Next. The Web Pages window appears as shown in Figure 54. Figure 54. Insert: Web Page 4. Complete the following steps: a. The Web pages window tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens: WebSphere Studio tools 57

68 i. Select the input page check box. ii. Select the output page check box. iii. Select the error page check box. b. Click Next. The Input Page window appears as shown in Figure 55. Figure 55. Insert: Input Page window 5. Complete the following steps: a. Select all of the check boxes by clicking the Check All button. b. Move the fields, using the up arrow and down arrow buttons, to interchange the order of the columns. c. Select the parameters by clicking on the row. Click Change button to change the caption to a more meaningful name. Repeat this for all the parameters. d. De-select the following fields: URL Driver UserID password e. Click the Next button to go to the next tab. The Results Page window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

69 Figure 56. Insert: Results Page window 6. Complete the following steps: a. Click the Uncheck All button to deselect all of the check boxes. b. Select Number of affected rows and SQL statement. c. Ensure that the Table radio button is selected. d. Click Next. The Standard Error Page appears as shown in Figure 57. Figure 57. Insert: Standard Error Page window 7. Click Next. The Methods window appears as shown in Figure 58 on page 60. WebSphere Studio tools 59

70 Figure 58. Insert: Methods window 8. Click Next. The Session window appears as shown in Figure 59. Figure 59. Insert: Session window 9. Complete the following steps: a. Select the Yes, store it in the user s session radiobuttonsothatthe generation bean will be placed in the session for the user. This makes the bean available for future use. b. Enter the name of the bean, iteminsertbean. Note that this is in lowercase letters. Case matters. c. Click Next. The Finish window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

71 Figure 60. Insert: Finish window 10.Complete the following steps: a. Give a meaningful name to the generated source files. Click the Rename button, and type ItemInsert into the Prefix dialog. CLick OK. Note that all of the files will now have the prefix of ItemInsert. b. Click Finish to generate the code. You should see the following files added to the DemoCompany project: ItemInsertInput.html ItemInsertResults.jsp ItemCustInsertError.jsp If you look inside the servlet->democompany folder, you also see that the following files have been created: ItemInsertDBBean.java ItemCustInsert.java ItemCustInsert.servlet ItemCustInsert.class ItemCustInsertDBBean.class 11.Check all of the generated files into Studio. Select the DemoCompany folder. Using the pop-up menu, select the Check In option. The files are already checked in if the Check In option is not available from the pop-up menu. 12.Publish the project to the server. Follow the same steps as described in 3.2.4, Publishing to the AS/400 system on page To test the publishing process, select the ItemInsertInput.html file from the publishing view to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. 14.When the Web browser appears, enter values for all the fields, as shown in Figure 61 on page 62, and click Submit to execute the query. WebSphere Studio tools 61

72 Figure 61. The input page The result is displayed as shown in Figure 62. Figure 62. The output page Creating an SQL UPDATE statement In this section, we create an SQL update statement to update a row in the Item database table. Follow these steps: 1. Select the DemoCompany project. 2. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. The Welcome window appears as shown in Figure 63. Figure 63. Studio SQL Wizard 62 Web Enabling AS/400 Applications with IBM WebSphere Studio

73 3. Complete the following steps: a. Enter UpdateItem as the name of the query. The wizard adds an.sql file in your project. b. Click Next. The Logon window appears as shown in Figure 64. Figure 64. SQL Update: Logon window 4. Complete the following steps: a. Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://sysname Userid: USERID Password: PASSWORD Driver: AS/400 Toolbox for Java Replace sysname with the name of your AS/400 system. Case is important for the Userid and Password; both should be in uppercase. b. Click Connect to connect to the specified database. c. Click the Next button to go to the next tab. The Tables window appears as shown in Figure 65 on page 64. WebSphere Studio tools 63

74 Figure 65. SQL Update: Tables window 5. Complete the following steps: a. Click Update in the Statement type. b. Select the APILIB.Item table from the list of tables shown. c. Click Next. The Update window appears as shown in Figure 66. Figure 66. SQL Update window 64 Web Enabling AS/400 Applications with IBM WebSphere Studio

75 6. Complete the following steps: a. Select the columns that are to be part of the Update statement by clicking in the value text field to enable the Parameter button. For each column, click the Parameter button, and then type the name of the parameter to enter a parameter value. b. Click Next. The Condition 1 window appears as shown in Figure 67. Figure 67. SQL Update: Statement window 7. Complete the following steps: a. Check if the correct table name is selected in the Selected table(s) drop-down list. b. Select the column name on which you wish to put a condition, which is IID (Item Number) in this case. c. Select the condition is exactly equal to, for example, from the Operator list box. d. Click on the Value field, and then click the Parameter button. Enter ItemNo for the field in the parameter dialog. e. Click OK. f. Click Next. The SQL window appears as shown in Figure 68 on page 66. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use in another application. You can also test the SQL statement by clicking the Run SQL button. WebSphere Studio tools 65

76 Figure 68. Update SQL statement 8. Click Next. The Finish window appears as shown in Figure 69. Figure 69. SQL Update: Finish window 9. Click Finish. 10.Check in the generated UpdateItem.sql file in the Studio Workbench Building the servlet using the SQL UPDATE statement We use the Database Wizard to create a servlet, which uses the SQL statement that we created in , Creating an SQL UPDATE statement on page 62. The Database Wizard helps you create Web applications that can query, insert, update, and delete relational data. 66 Web Enabling AS/400 Applications with IBM WebSphere Studio

77 Follow these steps to build the servlet using the SQL Update statement: 1. Select the DemoCompany project from the Studio Workbench. 2. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. The Database Wizard window appears as shown in Figure 70. Figure 70. Studio Database Wizard 3. Complete the following steps: a. Select the appropriate SQL statement \DemoCompany\UpdateItem.sql. b. Click Next. The Web Pages window appears as shown in Figure 71. Figure 71. Update: Web Page WebSphere Studio tools 67

78 4. Complete the following steps: a. The Web Pages window tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for update, an output page to show the result from the query, and an error page if something unforeseen happens: i. Select the input page check box. ii. Select the output page check box. iii. Select the error page check box. b. Click Next. The Input Page window appears as shown in Figure 72. Figure 72. Update: Input Page window 5. Complete the following steps: a. Click Check All to select all of the check boxes. b. Move the fields, using the up arrow and down arrow button, to interchange the order of the columns. c. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. Repeat this for all the parameters. d. Deselect the following fields: URL Driver UserID password e. Click Next. The Results Page window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

79 Figure 73. Update: Result Page window 6. Complete the following steps: a. Click the Uncheck All button to deselect all of the check boxes. b. Select the following items: Data ItemNo Name Price SQL Statement c. Ensure that the Table radio button is selected. d. Click Next. The Standard Error Page appears as shown in Figure 74 on page 70. WebSphere Studio tools 69

80 Figure 74. Update: Standard Error Page 7. Click Next. The Methods window appears as shown in Figure 75. Figure 75. Update: Methods window 8. Click Next. The Session window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

81 Figure 76. Update: Session window 9. Complete the following steps: a. Select the Yes, store it in the user s session radio button so that the generation bean will be placed in the session for the user. This makes the bean available for future use. b. Name the bean, itemupdatebean. Note that this is in lowercase letters, and case does matter. c. Click Next. The Finish window appears as shown in Figure 77. Figure 77. Update: Finish window WebSphere Studio tools 71

82 10.Complete the following steps: a. Give a meaningful name to the generated source files. Click the Rename button and type UpdateItem into the dialog. Click OK. Note that all of the files will now have the prefix of UpdateItem. b. Click the Finish button to generate the code. You should see the following files added to the DemoCompany project: UpdateItemInput.html UpdateItemResults.jsp UpdateItemInsertError.jsp If you look inside the servlet->democompany directory, you will also see that the following files have been created: UpdateItemDBBean.java IUpdateItem.java UpdateItem.servlet UpdateItem.class UpdateItemDBBean.class 11.Check all of the generated files in the Studio. Select the DemoCompany folder. Using the pop-up menu, select the Check In option. The files are already checked in if the Check In option is not available from the pop-up menu. 12.Publish the project to the server. Follow the same steps as described in 3.2.4, Publishing to the AS/400 system on page To test the publishing process, select the UpdateItemInput.html file from the publishing view to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. 14.When the Web browser appears, the page appears as shown in Figure 78. Enter values for all the fields, and click the Submit button to execute the update. Figure 78. The input page The result will be displayed as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

83 Figure 79. The output page Creating an SQL DELETE statement In this section, we create a SQL DELETE statement to delete a row from the Item database table. Follow these steps: 1. Select the project folder DemoCompany. 2. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. The Welcome window appears as shown in Figure 80. Figure 80. Studio SQL Wizard 3. Complete the following steps: a. Enter DeleteItem as the name of the SQL query. The wizard adds an.sql file in your project. b. Click Next. The Logon window appears as shown in Figure 81 on page 74. WebSphere Studio tools 73

84 Figure 81. Delete: Logon window 4. Complete the following steps: a. Enter the information that the wizard need to connect to the database, for example: Database URL: jdbc:as400://sysname Userid: USERID Password: PASSWORD Driver: AS/400 Toolbox for Java Replace sysname with the name of your AS/400 system. Case is important for the Userid and Password; both should be in uppercase. b. Click Connect to connect to the specified database. c. Click Next. The Tables window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

85 Figure 82. Delete: Tables window 5. Complete the following steps: a. Click Delete in the Statement type. b. Select APILIB.ITEM from the list of tables shown. c. Click Next. The Condition 1 window appears as shown in Figure 83. Figure 83. Delete: Condition window WebSphere Studio tools 75

86 6. Complete the following steps: a. Check if the correct table name is selected in the Selected table(s) drop-down list. b. Select the Item Id (IID) column from the columns field. This is the condition on which you want to delete the row from Item table. c. Select the condition, for example is exactly equal to, from the Operator list box. d. Click in the first value field. Then, click Parameter, and enter ItemID as the name of the parameter. e. Click Find to see the result of the conditional query. f. When the Value Lookup for the Item Id dialog appears, enter any valid Item Id in the search field. g. Click Find Now, and see which row gets deleted from the Item table. h. Click OK to return to the Condition 1 tab. i. Click Next. The SQL Statement window appears as shown in Figure 84. The SQL tab shows the completed SQL statement. You can copy the statement to the clipboard to use it in another application. Figure 84. Delete: SQL statement 7. Click Next. The Finish window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

87 Figure 85. Delete: Finish window 8. Click Finish. 9. Check in the generated DeleteItem.sql file in the Studio Workbench Building the servlet using the SQL DELETE statement We use the Database Wizard to create a servlet, which uses the SQL statement that we created in the previous section. The Database Wizard helps you create Web applications that can query, insert, update, and delete relational data. Follow these steps: 1. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. The Database Wizard window appears as shown in Figure 86. Figure 86. Database Wizard window WebSphere Studio tools 77

88 2. Complete the following steps a. Select the appropriate SQL statement \DemoCompany\DeleteItem.sql. b. Click Next. The Web Pages window appears as shown in Figure 87. Figure 87. Delete: Web Page window 3. Complete the following steps: a. The Web Pages window tab allows you to specify the HTML and JSP files that will be generated. You need an input page to input the data for deletion, an output page to show the result from the query, and an error page if something unforeseen happens: i. Check the input page check box. ii. Check the output page check box. iii. Check the error page check box. b. Click Next. The Input Page window appears as shown in Figure 88. Figure 88. Delete: Input Page window 78 Web Enabling AS/400 Applications with IBM WebSphere Studio

89 4. Complete the following steps: a. Select the IID (ItemId) check box. b. Select the IID line by clicking on the row. Click the Change button to change the caption to a more meaningful name. c. Click Next. The Results Page window appears as shown in Figure 89. Figure 89. Delete: Results Page window 5. Complete the following steps: a. Select all of the check boxes by clicking the Check All button. b. Deselect driver and userid options. c. Change all the captions to more meaningful names. d. Ensure that the Table radio button is selected. e. Click the Next button to go to the next tab. The Standard Error Pages window appears as shown in Figure 90. Figure 90. Delete: Standard Error Pages window WebSphere Studio tools 79

90 6. Click Next. The Methods window appears as shown in Figure 91. Figure 91. Delete: Methods window 7. Click Next. The Session window appears as shown in Figure 92. Figure 92. Delete: Session window 8. Complete the following steps: a. Select the Yes, store it in the user s session radiobuttonsothatthe generation bean will be placed in the session for the user. This makes the bean available for future use. b. Name the bean deleteitembean. Note that this is in lowercase letters, but case does matter. The Finish window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

91 Figure 93. Delete: Finish window 9. Complete the following steps: a. Give a meaningful name to the generated source files. Click the Rename button, and type DemoDeleteItem into the Prefix dialog. Click OK. Note that all of the files now have the prefix of DemoDeleteItem. b. Click the Finish button to generate the code. You should see the following files added to the DemoCompany project: DemoDeleteItemInput.html DemoDeleteItemResults.jsp DemoDeleteItemError.jsp If you look inside the servlet->democompany directory, you will also see that the following files have been created: DemoDeleteItemDBBean.java DemoDeleteItem.java DemoDeleteItem.servlet DemoDeleteItem.class DemoDeleteItemDBBean.class 10.Check all of the generated files in the Studio. Select the DemoCompany folder. Using the pop-up menu, select the Check In option. The files are already checked in if the Check In option is not available from the pop-up menu. 11.Publish the project to the server. Follow the same steps as described in 3.2.4, Publishing to the AS/400 system on page To test the publishing process, select the DemoDeleteItemInput.html file from the publishing view to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. 13.When the Web browser appears, the page appears as shown in Figure 94 on page 82. Enter a valid Item number that you want to delete from the ITEM table. Click the Submit button to execute the query. WebSphere Studio tools 81

92 Figure 94. The Input page on the browser The result is displayed as shown in Figure 95. Figure 95. The Output page on the browser Building a servlet using the JavaBean Wizard The JavaBean Wizard allows you to create servlets that interact with pre-built JavaBeans. In this section, we create a sample JavaBean using a Studio template. Then, we create a servlet, which uses the JavaBean, with the JavaBean Wizard. Follow this process: 1. Select the DemoCompany project. 2. Select Insert->File. A window appears with various templates for creating files. For example, you can create HTML files, JSP files, JavaBean files, and so on. 3. Select JavaBean.java from the list in the left-hand side of the Insert file window. Enter a more meaningful name for the file by entering Sample.java for File Name. The Insert file window is shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

93 Figure 96. Insert File window 4. Click OK to allow the file to be created in the project. Notice that Sample.java file is now listed in the file view. 5. Double-click on the sample.java file to open it. Change the class name to Sample instead of JavaBean. This bean has some properties defined and setter and getter methods defined for each of the properties. You see a commented line at the beginning of the file where you can add your package name if this JavaBean belongs to a package. The class extends to Java.lang.Object and has such properties defined as address, city, and so on. It has setter and getter methods for each of these properties. You can add your own code for making database connections and providing your own business logic. The sample JavaBean has the following properties FirstName LastName Age Address Phone City State Zip 6. Select the Sample.java file. Right-click, and select the Check In option from the pop-up menu to check in the file. 7. Select the Sample.java file. Right-click, and select the Compile option from the pop-up menu to compile the program. This creates a Sample.class file. 8. Check In the Sample.class file. 9. Select both the Sample.java and Sample.class files, and move them to servlet folder. We use the JavaBean Wizard to create a servlet that uses the Sample JavaBean. Complete this series of steps: 1. Select the DemoCompany project from the Studio Workbench. 2. Start the JavaBean Wizard by selecting Tools->Wizards->JavaBean Wizard. WebSphere Studio tools 83

94 The JavaBean Wizard window appears as shown in Figure 97. Figure 97. JavaBean Wizard 3. Complete the following steps: a. Select the appropriate JavaBean \DemoCompany\servlet\Sample.class. b. Click Next. The Web Pages window appears as shown in shown in Figure 98. Figure 98. JavaBean: Web Pages window 4. The Web Page window tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result of the query, and an error page to display errors. Complete the following steps: a. Check the input page checkbox. b. Check the results page checkbox. c. Check the error page checkbox. Click Next. 84 Web Enabling AS/400 Applications with IBM WebSphere Studio

95 The Input Page window appears as shown in Figure 99. Figure 99. JavaBean: Input Page window 5. Complete the following steps: a. Click Check All button to select all the check boxes. b. Click Next. The Results Page window appears as shown in Figure 100. Figure 100. JavaBean: Results Page window 6. Complete the following steps: a. Click Check All button to select all the check boxes. b. Click Next. The Standard Error window appears as shown in Figure 101 on page 86. WebSphere Studio tools 85

96 Figure 101. JavaBean: Standard Error window 7. Click Next. The Methods window appears as shown in Figure 102. Figure 102. JavaBean: Methods window 8. Click Next. The Session window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

97 Figure 103. JavaBean: Session window 9. Complete the following steps: a. Select the Yes, store it in the user s session radio button so that the generation bean will be placed in the session for the user. This makes the bean available for future use. b. Name the bean samplebean. Note that this is in lowercase letters, but case does matter. c. Click Next. The Finish window appears as shown in Figure 104. Figure 104. JavaBean: Finish window 10.Complete the following steps: a. Give a meaningful name to the generated source files. Click the Rename button. Type DemoSampleBean into the Prefix dialog. b. Click OK. Note that all of the files now have the prefix of DemoSampleBean. WebSphere Studio tools 87

98 c. Click Finish to generate the code. You see the following files added to the DemoCompany project: DemoSampleBeanInput.html DemoSampleBeanResults.jsp DemoSampleBeanError.jsp If you look inside the servlet->democompany directory, you also see that the following files have been created: DemoSampleBean.java DemoSampleBean.servlet DemoSampleBean.class The servlet configuration file is where the servlet finds the initial parameters to use. The initial parameters include the user ID, password, and the JDBC driver to use. The servlet configuration file has an extension of.servlet. 11.Check all of the generated files into Studio. Select the DemoCompany folder. Right-click, and select the Check In option. The files are already checked in if the Check In option is not available from the pop-up menu. 12.Publish the project to the server. Follow the same steps as described in 3.2.4, Publishing to the AS/400 system on page To test the publishing process, select the DemoSampleBeanInput.html file from the publishing view to preview it. Right-click, and select Preview file with Netscape or Internet Explorer. 14.When the Web browser appears, enter the values for all the fields, and click Submit. This shows the output page with the values of all the fields. 3.3 Page Designer With Page Designer, you can build complex Web pages, both visually and textually. Page Designer provides an advanced HTML editor that allows you to build dynamic content including form elements, Java applets, embedded scripts, dynamic controls, and JSP tags. Page Designer includes its own library of reusable graphics and two companion graphic programs, WebArt Designer and AnimatedGif Designer, that create, edit, and animate image files Using WebArt Designer and AnimatedGif Designer to add enhanced graphics In this section, we use WebArt Designer and AnimatedGif Designer to create graphics for use in Web pages. WebArt Designer helps you create GIF and JPG files. It comes with sample artwork, which you can modify or combine to create custom graphics. AnimatedGif Designer provides tools for creating animation from graphics files. You can combine the tools to create interesting animated graphics Registering the AnimatedGif Designer tool To register the AnimationGif Designer tool as the default program to run for GIF files, perform the following steps: 1. Select Tools->Tools Registration. The Tools Registration window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

99 Figure 105. Studio Workbench: Tools Registration window 2. Type gif for File extension, and click the Edit button. The Edit object type window appears with the MIME type tab selected as shown in Figure 106. Figure 106. Tools Registration: Edit Object Type window 3. Select the Editing Application tab. Then, select Animated Gif Designer from the left-hand list. 4. Click the Add-> button to add it to the right-hand list. 5. Remove any other registered tools by selecting them, and then click the Remove-> button. At this point, the Edit object type window appears as shown in Figure 107 on page 90. WebSphere Studio tools 89

100 Figure 107. Tools Registration: Edit Object Type window 6. Click OK and then the Close button to close the window Registering the WebArt Designer tool To register the WebArt Designer tool as the default program to produce GIF files, perform the following steps: 1. Select Tools->Tools Registration. The Tools Registration window appears as shown in Figure 108. Figure 108. Studio Workbench: Tools Registration window 2. Type mif for File extension and click the Edit button. The Edit object type window appears with the MIME type tab selected. 3. Select the Editing Application tab, and then select Web Art Designer from the left-hand list. 4. Click the Add-> button to add it to the right-hand list. 90 Web Enabling AS/400 Applications with IBM WebSphere Studio

101 5. Remove any other tools registered by selecting them. Then click the Remove-> button. At this point, the Edit object type window appears as shown in Figure 109. Figure 109. Tools Registration: Edit Object Type window 6. Click OK and then the Close button to close the window Creating the banner and logo buttons We create a banner and logo buttons for ABC Company using WebArt Designer. They are used as the base gif files for the design of the site discussed in Chapter 7, ABC Company Web site design and development on page 157. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Open the DemoCompany project. 3. Create a folder named Images under the DemoCompany project. Right-click on DemoCompany, andselectinsert->folder from the pop-up menu. Then, enter Images as the folder name. 4. Select the Images folder, and then select Insert->File. When the dialog appears, select WebArtDesigner.mif as the file type. Enter banner.mif as the file name (Figure 110 on page 92). WebSphere Studio tools 91

102 Figure 110. Insert File window 5. Click OK to cause the banner.mif file to be created in the images folder. 6. Open the new banner.mif file in the WebArt Designer. a. Select banner.mif. b. Right-click, and select Edit with->webart Designer. The WebArt Designer opens with a canvas. Note that the left-hand side of the WebArt Designer is a tabbed frame, which allows you to select existing graphics and drag them to the canvas. 7. Create the banner.gif file, which is used as the banner for the ABC Company site: a. From the WebArt Designer, modify the size of the canvas by selecting File->Preferences->Display Tab. Enter a width of 250 and a height of 150. Click on the WebSphere logo and press the Delete key to delete it. Change the color by selecting the Background tab on the left side of WebArt Designer and dragging the white square onto the canvas. b. Select the Button tab from the left-hand bottom corner. Drag the circle09 button to the left top corner of the canvas. Right-click on the button, and select Properties from the pop-up menu. Enter a width of 89 and height of 89 so that the circle resizes to 89 x 89. c. Double-click on the circle button on the canvas. The Edit Button Object window appears. Select the Color tab. Select Plain Color for Group and Blue for Type. Close the Edit Button Object window. d. Click the Logo tab on the left-hand, bottom corner of the page. Drag the engrave logo to the canvas so that it is on top of the circle. e. Double-click on the engrave logo so that the Edit Logo Object window appears with the Text and Font tab selected. Enter ABC Company for Text, set 56 for Font Size, Anti-alias for Style, and Left for alignment. Select the Color tab. Set Plain Color for Group and Yellow for Type. Click the Outline tab, and select Normal for Type. Click the Logo Effect tab, and select Cut Out for Type. The window at this point appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

103 Figure 111. WebArtDesigner: The ABC Company banner f. Select File->Save Wizard. Select the Object Only radio button, and then click Next. SelectGIF as the image file format. Click Next, and then click Finish. Navigate to the Image folder in your workstation, and save the file as banner.gif. With GIF files, you can specify transparency as the part of image, where with JPEG, you cannot specify transparency. Note: Ensure that no object on the canvas is selected before you save the wizard. g. Close the WebArt Designer, and save the banner.mif file. 8. Create the buttons for navigation. Follow step 4 to create a general.mif file. 9. Right-click on the general.mif file to edit it with WebArt Designer: a. From the WebArt Designer, modify the size of the canvas by selecting File->Preferences->Display Tab. Enter a width of 250 and a height of 150. Delete the WebSphere logo by clicking on it and press the Delete key. Change the color by selecting the Background tab on the left side of WebArt Designer and dragging the white square onto the canvas. b. Select the Button tab from the left-hand, bottom corner, and drag the circle09 button to the left top corner of the canvas. Right-click on the button, and select properties from the pop-up menu. Enter a width of 29 and height as 29 so that the circle resizes to 29 x 29. c. Double-click on the circle button on the canvas. The Edit Button Object window appears. Select the Color tab. Select Plain Color for Group and Blue for Type. Close the Edit Button Object window. d. Click the Logo tab on the left-hand, bottom corner of the page. Drag the engrave logo to the canvas so that it is on top of the circle. e. Double-click on the engrave logo so that the Edit Logo Object window appears with the Text and Font tab selected. Enter About Us for Text. Set the Font Size to 30, Style to Anti-alias, and Alignment to Left. Select the Color tab, and set Plain Color for Group and Yellow for Type. Click the Outline tab, and select Normal for Type. Click the Logo Effect tab, and select Emboss for Type. The window, at this point, appears as shown in Figure 111. f. Select File->Save Wizard. Select the Object Only radio button, and then click the Next button. Click GIF as the image file format. Click Next, and then click Finish. Navigate to the Image folder in your workstation and save the file as aboutus.gif. With GIF files, you can specify transparency as the part of image, where with JPEG, you cannot specify transparency. WebSphere Studio tools 93

104 10.While in the WebArt Designer, double-click on the text object in the right palette. Select the Text and Font tab from the window and replace the text with About Site. This way, you ensure that the alignment is not disturbed and the size and color are consistent for all the buttons. 11.Select File->Save Wizard. SelecttheObject Only radio button, and then click the Next button. Click GIF as the select image file format. Click the Next button, and then click Finish. Navigate to the Image folder in your workstation, and save the file as aboutsite.gif. 12.Repeat steps 10 and 11 to create buttons for the main page and the generate user page. Name them welcome.gif and generate.gif. 13.Close WebArt Designer, and save general.mif for further use. You can use this procedure to create as many buttons you need for the site Creating animated images You can create an animated GIF, which involves creating several graphics and then combining them together in an animation object. It is a redbook image that spins continuously. Follow these steps to create the redbook animated image: 1. Select the Images folder, and then select Insert->File. When the dialog appears, select WebArtDesigner.mif asthetypeoffile.enterbook.mif as the name of the file. 2. Click the OK button to cause the book.mif file to be created in the Images folder. 3. Right-click on the book.mif file to edit it with WebArt Designer. 4. From the WebArt Designer, modify the size of the canvas by selecting File->Preferences->Display Tab. Enter a width of 250 and a height of 150. Delete the WebSphere logo by clicking on it and pressing the Delete key. Change the color by selecting the Background tab on the left side of WebArt Designer and dragging the white square onto the canvas. 5. Drop an image of a book onto the canvas. Select the other tab in the left-hand, bottom corner, and navigate to the \WebSphere\Studio\icons directory. Select the book.gif image. Drag the image to the canvas, and place it in the center of the canvas. 6. To make the image look like a redbook, you need the redlogo.gif file, which is available from the SG EXE self-extracting file (refer to Appendix A, Example programs on page 405, for more information). If you downloaded it, place it in the \DemoCompany\images folder. 7. Right-click on the book on the canvas, and select properties. Set the width to 94 and the height to 81. Click on the other tab from the left-hand, bottom corner, and navigate to the \DemoCompany\images folder. Drag the redlogo.gif file to the canvas to place it on top of the book. Resize the redlogo.gif image to fit the book so that it looks like a redbook. 8. Select both the objects by using the Shift key. Then, select Object->Combine. This combines both objects into one. The image at this point appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

105 Figure 112. The redbook image 9. Create the remaining graphics for the animation. You need to add effects to make it look like the redbook is spinning. In this process, you create a number of GIF files that together can create an animation effect. Complete these tasks: a. With the redbook selected, select Tool->Effect to open the Effects Palette window. b. Click the Preview button. All of the available effects are applied to the redbook and shown in the Effects Palette window (Figure 113). Figure 113. WebArt Designer: Effects Palette window c. While in the Effects Palette window, select the Turbulence icon, and click Apply. Notice that the image changes. Click on the WebArt Designer window. WebSphere Studio tools 95

106 d. Click File->Save Wizard, selectobject Only, and click Next. Select GIF as the image file format. Click Next, and then click Finish. Navigatetothe \DemoCompany\Image folder in your workstation, and save the file as book11.gif. e. Select Edit->Undo to get the original image of the redbook. f. Repeat these steps to create more images. Select the Effect type and the name as shown in Table 1. Table 1. Effect types and file names Effect type File name Vortex Mirage Bubble Flat Mosaic Blur Tile Sharp book12.gif book13.gif book14.gif book15.gif book16.gif book17.gif book18.gif book19.gif g. Close the WebArt Designer window. h. From the Studio Workbench, check in all the files. 10.Use WebSphere AnimationGif Designer to put all the graphics created together into an animation. a. From the Studio Workbench, select the images folder. Create a new animation file by selecting Insert->File. When the dialog appears, select a file type of Animation.gif, and name the file as book.gif. b. Click the OK button. When prompted to check out the file, click the Check Out button. c. To edit with AnimationGif Designer, select Edit with->animationgif Designer. d. When the AnimationGif Designer opens, select File->Animation Wizard. e. When the wizard starts, click the Add Image File button. When the open file dialog appears, select the following files in order, and click the Open button: \DemoCompany\images\book11.gif \DemoCompany\images\book12.gif \DemoCompany\images\book13.gif \DemoCompany\images\book14.gif \DemoCompany\images\book15.gif \DemoCompany\images\book16.gif \DemoCompany\images\book17.gif \DemoCompany\images\book18.gif \DemoCompany\images\book19.gif \DemoCompany\images\book19.gif \DemoCompany\images\book19.gif \DemoCompany\images\book19.gif 96 Web Enabling AS/400 Applications with IBM WebSphere Studio

107 f. Notice that book19.gif was used multiple times. This is to make the animation sequence more realistic. Click the Next button. g. Specify that the frame center should be put on middle center, and click Next. h. Specify that the animation should be set to an Infinite number of repeats, and the delay is 200 msec. Click the Next button. i. On the Finish panel, click the Play button and preview the animation. The AnimatedGif Designer, at this point, appears as shown in Figure 114. Figure 114. AnimatedGif Designer: Redbook animation j. If everything looks good, click Finish. k. Save the animation as a bookani.gif animation file by selecting File->Save As. l. Close the AnimatedGif Designer window. 11.To add the bookani.gif file to the Studio Workbench publishing stage, follow these steps: a. Select the Images folder. b. Right-click, and select Insert->File. c. Select the Use Existing tab. d. Locate bookani.gif in the \DemoCompany\images folder, and click the OK button. e. Check in all the files Constructing the Logon page In order for users to navigate and shop at the ABC Company Web site, users need to be a registered member of this site. The Logon page takes the user ID and password as input from the user and verifies whether the user is registered in the database. If the userid and password are valid, the user is allowed to navigate and shop at the ABC Company Web site. WebSphere Studio tools 97

108 In this section, we build the front end for the Logon page, which will be offered to the user over the Internet. Later in Chapter 8, Creating the complete ABC Company Web site on page 361, we build a servlet, which provides the back-end functionality of validating the userid and password. As you go through this section, refer to Figure 118 on page 102 as a guide for the completed page: 1. Add a new folder named ABC_Company to the DemoCompany project. 2. Create the Logon page, and call it Logon.html. a. From the Files view of the Studio workbench, select the ABC_Company folder, and then select the Insert->File menu option. A dialog displaying many types of files which can be added to a WebSphere Studio project appears. Select the Blank.html file on the left, and then supply a file name of Logon.html. The Insert File window appears as shown in Figure 115. Figure 115. Studio: Login page creation b. Click the OK button. Then, the file Logon.html is created and added to the Studio Workbench. 3. Double-click the file to open it. When the file opens, the Normal mode tab of the Page Designer is selected. Delete the Put your text here sentence. 4. Change the Document Title to Logon Page by selecting the Document Properties menu option from the pop-up menu. Since Document Properties is the top-level object for everything in the Normal view of Page Designer, the mouse can be positioned over any object in the page. 5. Click OK to close the Attributes dialog window. 6. Add the banner to the page. Our banner is banner.gif, which we created in 3.3.1, Using WebArt Designer and AnimatedGif Designer to add enhanced graphics on page 88. a. To ensure that the images and text that you place on the Logon.html page have the same layout at display time that they have at edit time, you must use tables for placing the items. b. Insert a Table containing two columns and two rows at the top of the page. Select Insert->Table. A dialog is displayed requesting the number of columns and rows. Enter 2 for the columns and 2 for the number of rows. Close the Insert Table dialog by clicking OK. 98 Web Enabling AS/400 Applications with IBM WebSphere Studio

109 c. A 2 X 2 table will be added to the page and has borders. Remove the borders by changing the table attributes. Select the table. Right-click, and select Attributes to view the Attributes dialog. A dialog showing the table attributes appears. Select the Table tab. Deselect the Show Border check box. Enter 0 for Cell Spacing and Cell Padding, which leaves no room between the cells. The table attribute window should look like the example shown in Figure 116. Click OK to save the new settings. Figure 116. Page designer table attributes d. Select the top row of the table so that the cursor is inside the top row and second column. Then, select Insert->Image. Addthe \DemoCompany\images\banner.gif file to the table. Notice that the table expands to accommodate the image. 7. Select the top row of the table so that the cursor is inside the top row and the first column. Then, select Insert->Image. Addthe \DemoCompany\images\bookani.gif file to the table. 8. Add a column of buttons for navigation purposes: a. Add a table inside the first table. Do this by placing the cursor in the second row first column of the table. b. Add another table by selecting Insert->Table. When the dialog appears, specify 4 rows and 1 column. We place four images in this table to function as a button bar. Close the Insert Table dialog by clicking OK. c. Modify the table attribute for the new table. Select the new table, and then open the Attribute dialog by double-clicking on the table. Select the Table tab, and then de-select the Show Border check box. Enter 0 for Cell Spacing and Cell Padding as this leaves no room between the images. Click OK to save the new settings. The Logon page appears as shown in Figure 117 on page 100. WebSphere Studio tools 99

110 Figure 117. Inserting a table inside the outer table 9. To add the images, place the mouse cursor inside of a cell in the inner table, and then select Insert->Image to add the images. Add the About Us button to the inner table. This involves adding an image and a link: a. With the first cell in the inner table selected, select Insert->Image to open the Insert Image dialog and the File Selection dialog simultaneously. b. Navigate to the \DemoCompany\images\aboutus.gif file, and click the Open button. The File Selection dialog and the Insert Image dialog will close. c. Add a link by selecting the Insert Link option from the Image pop-up menu. At this point, you do not actually add the link. That is discussed in Chapter 8, Creating the complete ABC Company Web site on page 361. Click the Cancel button to close the Attributes dialog window. d. Add the remaining buttons to the inner table by following the instructions used to add the About Us button. Assume that all of the files are in the directory \DemoCompany\images. The images to add to the Logon page are: aboutsite.gif generate.gif welcome.gif 10.Create an HTML form in the second column, second row of the outer table. This form contains the necessary items for the user to enter the user ID and password to log in and navigate the site. The form contains a table with labels, entry fields, and buttons. a. You need to add a form inside the outer table. Place your cursor in the second row in the second column of the table. 100 Web Enabling AS/400 Applications with IBM WebSphere Studio

111 b. Select Insert->Form and Input Fields->Form to add a form to the selected cell of the outer table. c. Click on any point inside the form and add another table. This table serves as the layout mechanism for the Form field. Add the table by clicking Insert->Table. Make this table with 3 columns and 2 rows. d. Since this table is for layout purposes, you want it to be invisible or hidden to the Web user. Select the table, right-click, and select Hide Table Frame from the pop-up menu. e. With the inner table still selected, open the attributes dialog by selecting the Attributes option from the pop-up menu. Select the Table tab, and then set the alignment to Center. Click the OK button to save the new settings. f. Make the table larger by grabbing one of the corners and stretching it horizontally. g. Add the userid label and text fields: i. Select the top, left-most cell, and type Userid in the cell. Select Format->Physical Emphasis->Font. Enter a size of +1, acolorof Black, and a Face of Arial. Click OK to close the dialog. ii. With userid still selected, select Format->Physical->Emphasis->Bold. iii. Press the Tab key twice to select the right-most cell in the same row. Leave the middle cell empty to have a space between the label and the text field. Enter an input field by selecting Insert->Form and Input Fields->Text Field. The Attributes dialog opens on the Text Field tag. Enter userid as the name of this field. Set both the Columns and Maximum Length to 20. Click OK to close the Attributes dialog. h. Add the password label and the Text field for password. Use the same steps as above. 11.Add another table below the table used for the user ID and password: a. Add a table of 2 rows and 3 columns to hold the buttons. Leave the first row and second column empty to have a gap in between, and use the second row to insert the buttons. b. Since this table is for layout purposes, you want it to be invisible or hidden to the Web user. Select the table, right-click, and select Hide Table Frame from the pop-up menu. c. Add a Submit button by selecting the second row in the first column of the table. Select Insert->Form and Input Fields->Push Button->Submit Button. When the Attributes dialog opens on the Push button tag, enter a Name of submit, a Label of Submit, and Button Type of Submit. Click OK to save the settings. d. Add a Reset button by selecting the second row in the third column of the table. Select Insert->Form and Input Fields->Push Button->Reset Button. When the Attributes dialog opens on the Push button tag, enter a Name of reset, a Label of Reset, and Button Type of Reset. Click OK to save the settings. Figure 118 on page 102 shows the completed Logon page. WebSphere Studio tools 101

112 Figure 118. Page Designer: Viewing the final Logon page 12.Close the Page Designer, and respond Yes to the dialogs requesting that you save the files. 13.Use the Check In menu to check the Logon.html file into the Studio Workbench Creating a page template One of the interesting features of WebSphere Studio is that we can create a file using the existing templates within the WebSphere Studio. Also, WebSphere Studio allows you to add a custom design template to the list of templates and reuse this template in the future. Normally, while building a Web site, a developer would want a site template in place so that it becomes easier for reusing the template. The template created in this section is used as the base template for building the ABC Company Web site. Follow these steps: 1. Double-click the Logon.html file (created in 3.3.2, Constructing the Logon page on page 97) to open it in Page Designer. 2. Select the content of the second row in the second column of the outer most table. This has the field to enter the password. Press the Delete key to delete the content of the cell. 3. Make sure that the cell, second row, and second column of the outer table are empty. The page appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

113 Figure 119. Page Designer: Creating a page template 4. Select File->Save As. The Save As dialog appears, which prompts you for the file name. Enter SiteTemplate.html as the name. Click the Save button to save the file. 5. From the Studio Workbench, select SiteTemplate.html, and check in the file. 6. Open Windows Explorer, and navigate to find the SiteTemplate.html file. Right-click, and select Copy from the pop-up menu. Navigate to the \WebSphere\Studio\templates folder and paste the SiteTemplate.html file into it. 7. Go back to the Studio Workbench. Select Insert->File, and the Insert File window appears. You should now be able to view the SiteTemplate.html as one of the templates in the list. Select it, and enter a meaningful name. Click OK to add the file to the WebSphere Studio project. 8. Open the file by double-clicking on it. Make sure that the file template is the one you created Working with style sheets Style sheets are a way for publishing professionals to manage the overall look of their publications. They control the background, colors, fonts, and all elements of style that publishing professionals want to reuse for a large set of documents. Web publishing professionals have the same needs and, as such, can use a concept know as cascading style sheets. There are three ways to attach a style to a tag: inline, document-level, andexternal style sheets.eachofthesetypesof style is merged by the browser, giving the ability to have a master style sheet (external), which is used for an entire Web site while still allowing each specific page to override style elements locally. Style sheets are somewhat new, so not all versions of Web browsers fully support them. Follow these steps: WebSphere Studio tools 103

114 1. Open the DemoCompany project if it is not already open. 2. Look at how the style sheets are being used: a. The master style sheet can be found in the theme directory and is called Master.css. b. In the Studio Workbench file view, select the Master.css file. You will see in the relations view that Master.css is related to all the files under this project. This means all the files in this project use the Master style sheet. c. Double-click the Logon.html page to open it in Page Designer. d. To see the style of this page, select View->Style Sheet Manager from Page Designer. e. The style manager dialog opens with the Show the style list button selected. From this dialog, you can add, delete, and edit document styles. Additionally, from this dialog, you can drill down on external style sheets and then add, delete, and edit elements of style in the external style sheet. The style sheet window appears as shown in Figure 120. Figure 120. Page Designer: Style Sheet Manager status f. To see how various styles are used in this page, select the Show current style status button at the top of the window. Selecting this button shows all the types of tags found in the document. Then, it shows which tag is actually being used. This is valuable for many reasons. If you have more than one style for a tag, the current style status view shows which style is actually being used for the tag. 3. You want all the H1 tags for the entire site to have a color of Red. This style needs to be placed in the Master.css external style sheet so that all pages can use the external style sheet and have H1 tags in the color of Red. a. While still in Style Sheet Manager dialog window, select the Show the style list->master.css. Click the Edit button. The External Style Sheet dialog window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

115 Figure 121. Page Designer: External Style Sheet b. Add a new style to this external style sheet. Select Add->Create, and click the Add The Style button. The Style Definition dialog appears. c. Ensure that the Set the style to the HTML tag is selected. We want this style to apply for all H1 tags. d. Change the HTML tag List to H1 by selecting it from the drop-down list. e. Select the Color and Background tab, and then select red from the drop-down list of colors. f. Click OK to close the Style Definition dialog. Then, click OK to close the External Style Sheet dialog. g. From the Studio Workbench, double-click on the Logon.html pagetoopen it. Select some text on the page. Assign it an H1 tag by selecting Insert->Paragraph->H1. Notice that the text changes color to red. 4. In the previous step, you changed the Master.css by opening an HTML document that used the Master.css file. Here, we edit the Master.css file directly: a. The master style sheet is found in the theme directory and is called Master.css. b. In the Studio Workbench file view, double-click on the Master.css file to open it in the Page Designer. Upon opening this file, notice that the Page Designer opens the External Style Sheet dialog. c. Change the background to a bitmap. To do this, select the <BODY> tag, and then click the Edit button. The Style Definition dialog appears. d. Select the Color and Background tag. From this tab, click the Browse button beside the Background Image label and navigate to the \DemoCompany\images\ directory. Select one of the GIF files, and click Open. e. Click OK twicetoreturntostudioworkbench. WebSphere Studio tools 105

116 f. From the Studio Workbench, open the Logon.html page. Notice that the background now contains a pattern of the GIF file you chose Using Page Designer with JavaBeans We use the facilities provided by WebSphere Studio Page Designer to create dynamic pages that interact with servlets created by the Studio Wizards. We use the JavaBean and the servlet created in , Building a servlet using the JavaBean Wizard on page 82. To do this, we use the wizlet function of WebSphere Studio, as demonstrated in the following steps: 1. Create a new HTML page using the page template you created. Follow these steps: a. With the ABC_Company folder highlighted, select the Insert->File menu option. When the Insert File dialog appears, select SiteTemplate.html from the list, and enter DemoBean.html as the file name. b. Click OK to add the file to Studio Workbench. 2. Double-click the DemoBean.html page in Page Designer to open it. 3. With the Page Designer open, go to the Studio Workbench. Select the Sample.class JavaBean that was generated in , Building a servlet using the JavaBean Wizard on page 82. Note Make sure that you select the JavaBean and not the servlet to drop on the page. In , Building a servlet using the JavaBean Wizard on page 82, the JavaBean is Sample.class. 4. Right-click on the Sample.class file. From the pop-up menu, select Copy as HTML Script. A dialog appears that looks much like the Database Wizard. This is a wizlet, which allows you to generate an Input or Results page from a JavaBean. Select the Input Page radio button. The wizlet window looks like the example in Figure 122. Figure 122. Wizlet window 106 Web Enabling AS/400 Applications with IBM WebSphere Studio

117 5. Click Next to go to the next window in the wizlet. On this window, you must select the fields that you want to be displayed on the input page. Click Check All to select all the fields. Select each row and click Change to change the caption of each field to a meaningful name. Use the Up and Down arrows if you want to reorganize the order of fields. 6. Click Next. The next window shows the generated HTML. Click Finish to copy the contents of the panel to the copy and paste buffer. At this point, the dialog closes and you return to the Studio Workbench. The HTML is in your copy and paste buffer. 7. Return to the Page Designer window to edit the DemoBean.html file. Place your mouse cursor in the empty cell of the table, in the second row and second column of the outer table. Select Edit->Paste. A form is then painted on the page. The DemoBean.html page now appears as shown in Figure 123. Figure 123. Page Designer: Page created using a JavaBean Wizlet 8. In the Studio Workbench, select the servlet servlets/democompany/demosamplebean.servlet. Right-click on this file. From the pop-up menu, select Copy as URL Text to copy the servlet URL into the copy and paste buffer. 9. In Page Designer, select the form and open the Attributes dialog by double-clicking on the form. Use the drop-down list to select the Form tag. Change the action to call the generated servlet by pasting the name into the action field. As shown in Figure 124 on page 108, the action should be /servlet/democompany.demosamplebean. Ensure that the Method radio button is set to POST. WebSphere Studio tools 107

118 Figure 124. Form Attribute window 10.Click OK to save your settings. 11.Close the Page Designer window, and save your work. 12.From the Studio Workbench, check in the DemoBean.htm file. 13.Publish the DemoBean.html file. Refer to 3.2.4, Publishing to the AS/400 system on page 46, if you still need help for the publishing task. 14.To test the publishing process, select the DemoBean.html file from the publishing view, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the input page appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

119 Figure 125. Page Designer: Using a JavaBean in a Web page In this section, we demonstrated how to use a JavaBean in a Web page. In our case, the JavaBean did not have any business logic. Chapter 8, Creating the complete ABC Company Web site on page 361, shows you how to add logic to your JavaBeans Modifying the Studio Wizards generated result page The output page generated by the Studio Wizards appear in a simple format. The generated page can be updated for added functionality. For example, you could add a column for calculating totals. Here, we modify the Studio Wizards generated results page to enhance the overall look of the output page. In this example, we use the Studio Wizards generated output file from , Building the servlet using the SQL SELECT statement on page 39. We add a banner to the output page. Here are the steps for this process: 1. In Page Designer, open the ItemSearchInput.html file generated in , Building the servlet using the SQL SELECT statement on page 39. The Studio Wizards generated input file is shown in Figure 126 on page 110. WebSphere Studio tools 109

120 Figure 126. Page Designer: Studio Wizard generated input file 2. Place the cursor on the top of the output page. 3. To ensure that the banner image and the content of the input file have the same layout at display time that it has at edit time, use tables for placing the items: a. Insert a table containing one column and one row at the top of the page by selecting Insert->Table. A dialog is displayed that requests the number of columns and rows. Enter 1 for the column and 1 for the number of rows. b. A one column by one row table is added to the page, which also has borders. Remove the borders by changing the table attributes. Select the table. Right-click, and select Attributes to open the Attributes dialog. A dialog showing the table attributes appears. Select the Table tab and then de-select the Show Border check box. Enter 0 for Cell Spacing and Cell Padding. This leaves no room between the images. c. Click OK to save the settings. 4. Add the banner image to the cell in the table. Select the cell of the table so that the cursor is inside the cell. Then, select Insert->Image. Addthe \DemoCompany\images\banner.gif file to the table. Notice that the table expands to accommodate the image. 5. Resize the width of the cell to that of the input page content. Right-click in the table cell and select Attributes. Then, enter the appropriate cell width to resize the cell to the width of the output page. The modified output page at this point appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

121 Figure 127. Page Designer: The modified input page 6. Close the Page Designer window, and save your work. 7. From the Studio Workbench, check in the ItemSearchInput.html file. 8. Publish the ItemSearchInput.html file. Refer to 3.2.4, Publishing to the AS/400 system on page 46, if you still need help for the publishing task. 9. To test the publishing process, select the ItemSearchInput.html file from the publishing view. Right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the input page appears as in Figure 128. Figure 128. Page Designer: The final modified input page WebSphere Studio tools 111

122 3.4 Applet Designer Applet Designer allows you to visually construct Java applets. You drag and drop JavaBeans from a palette onto a canvas to construct applets. Applet Designer includes a number of JavaBeans that you access from the palette. You can also add your own JavaBeans to the palette. The JavaBeans included with the Applet Designer include user interface controls such as buttons and check boxes; multimedia beans for adding images, audio, roll-overs, ticker tapes and other effects to your applet; and networking beans for , database, and Web access in your applet Creating an applet with Applet Designer Animated redbook file This section uses the animated redbook file created in , Creating animated images on page 94. It is named bookani.gif. You, too, can use the animated book object, which is available from the self-extracting file SG exe file called book.gif. Refer to Appendix A, Example programs on page 405, for more information on how to download the SG exe self extracting file from the ITSO Web site. In this section, we build an applet that displays the animated redbook. It has start and stop buttons, which causes the book to spin and stop spinning respectively. To create the applet, follow these steps: 1. Open the DemoCompany project if it is not already open. 2. From the Studio Workbench, create a new folder to hold the files created by Applet Designer. Select the DemoCompany folder, and then select Insert->Folder. When the dialog appears, enter the new folder name as AppletDesigner. Click OK to close the dialog and create the folder. 3. Select the AppletDesigner folder, and create a new Applet Designer file by selecting Insert->File. From the dialog, select a file type of AppletDesigner.app, and enter a name of WebSphereNJava.app. WebSphere Studio creates the file and places it in the AppletDesigner folder. 4. Open the AppletDesigner folder, and double-click on the WebSphereNJava.app file to start the Applet Designer. When Applet Designer opens, the New Applet Wizard also opens. The New Applet Wizard window appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

123 Figure 129. Applet Designer: Applet Wizard 5. Click Next to bypass the Welcome Page. Deselect the check box if you do not want the wizard to automatically start next time. 6. On the Animation page, select the Yes, please, and Medium (for the speed) radio buttons, and click Find. 7. Select the \DemoCompany\images\bookani.gif file. Click Open to select the first image in the animation. Figure 130 shows the current wizard view. Figure 130. Applet Designer: Previewing the animation 8. Click Preview to see how the animation is going to look before placing it on the applet. 9. Click Finish to generate the animation. 10.As shown in Figure 131, you see a white area (Applet1) and a red color book. WebSphere Studio tools 113

124 Figure 131. Applet Designer: The generated animation 11.Click the book, and set the Autostart property to No in the Properties window. 12.Select and resize Applet1 to provide enough space to place other beans. Center the book image in the top part of the applet: a. The applet resizes itself if you drop controls on it. You can also select Layout->Set To Preferred Size, which sizes a control to its preferred size if it has one. b. If you cannot select Applet1 by clicking on the white area, click Selected Bean drop-down list at the top of the Composer window, and select Applet1 from the list of beans. 13.In the left-hand frame (from the Palette frame), select the Controls tab, and click on the Button icon. 14.Place two buttons, to the left and right of the book, on Applet1. These buttons will serve as the Start and Stop buttons for the animation. Refer Figure 132 on page 116 as a guide. 15.Select both buttons and align them horizontally (press the Shift key and left-click to select multiples; select Layout->Align->Middle to align). If you select the Undo menu option, the alignment will be undone. 16.Select Button1. In the Properties frame, change the Label to Start. Additionally, change Name to StartPB. 17.Select Button2. In the Properties frame, change the Label to Stop. Additionally, change Name to StopPB. 114 Web Enabling AS/400 Applications with IBM WebSphere Studio

125 Bean names It is also a good idea to give more meaningful names to beans. Meaningful names make it is easier to create correct connections. If you ever need to create a new Java method on your applet, it will be much easier to code with meaningful bean names. 18.When the Start button is pressed, you want the animation to begin. To do this, you need to establish a connection that will fire when the Start button is clicked. a. Click the Start button. Then, click in the first cell of the Connection frame at the bottom. b. For each element in the table, select a provided value from the drop-down list. Even if the value you want automatically appears in the cell, you must click the drop-down button, and select it again. For each column, select the following options: When -> clicked Bean-> Animation1 Do -> start c. Ensure that when you are finished, the connection is not red. Incomplete connections are in the color red. 19.When the Stop button is clicked, you want the animation to end. To do this, you need to establish a connection that will fire when the Stop button is clicked. a. Click the Stop button. Then, click in the first cell of the Connections frame. b. For each element in the table, select a provided value from the drop-down list. Even if the value you want automatically appears in the cell, you must click the drop-down button, and select it again. For each column, select the following options: When -> clicked Bean-> Animation1 Do -> stop c. Ensure that when you are finished, the connection is not red. Incomplete connections are in the color red. At this point, the Applet Designer window looks similar to Figure 132 on page 116. WebSphere Studio tools 115

126 Figure 132. Applet Designer: The completed applet 20.Test your applet by selecting File->Run. Figure 133. Applet Designer: The animated redbook Placing a Rollover button on the applet and connecting it to a URL In this section, we add a rollover button, which, when pressed, opens the IBM WebSphere Web site. A rollover button changes its state when the mouse passes over it. Also, when the button is clicked, it changes its state again. To create the Roll Over, follow these steps: 1. Select the Multimedia tab in the Palette window. 2. Click on the Rollover icon, and place it below the book. 116 Web Enabling AS/400 Applications with IBM WebSphere Studio

127 3. When the dialog box appears, use the Find buttons to locate the three pictures for the Rollover button: Note The following GIF files are available from the SG self-extracting file. If you have restored this file as described in the ReadMe file, they should be located at the \Redbook\Code5634 directory. Button Picture\Redbook\Code5634\WebSph.gif Pressed Picture\Redbook\Code5634\WebSphp.gif Rollover Picture\Redbook\Code5634\WebSpho.gif Refer to Appendix A, Example programs on page 405, for more information on how to download the SG exe self-extracting file from the ITSO Web site. 4. Select On rollover for a 3-D effect, and click Done. 5. Click the Networking tabinthepalettewindow,andselecttheurl Link bean. 6. Place the URL Link somewhere on the Applet Designer surface. Logically, this bean should be placed outside of the applet (white surface). However, inside or outside of your applet, it is not visible at runtime. 7. In the Properties frame, enter the URL address: 8. Click on the Rollover picture, and select the Connections frame. For each column, select the following options: When-> clicked Bean-> URL Link1 Do-> show document Ensure that when you are finished, the connection is not red. Incomplete connections are in the color red. 9. Run the applet again, and test the Rollover button. If you click the Rollover picture nothing happens. In the applet viewer you cannot go to the URL. This can only be done in a browser. The animated redbook with the Rollover button window appears as shown in Figure 134 on page 118. WebSphere Studio tools 117

128 Figure 134. Applet Designer: Animated redbook with Rollover button Creating nervous text on the applet In this section, we add nervous text to the applet and make connections so that when the cursor enters the text area, the text starts to jump. It stops jumping when the cursor is moved out of the text area. Follow these steps: 1. Select Multimedia in the Palette window. 2. Click on the Nervous Text icon, and then place it below the rollover button. 3. In the Properties frame of Nervous Text1, change the text to WebSphere Studio is Cool! 4. Set Autostart to No and Anxiety Level to Calm. 5. Set Font to Sans Serif, bold, In Connections, select the following items: When-> mouse entered Bean-> Nervous Text1 Do-> start 7. In Connections select, the following options: When-> mouse exited Bean-> Nervous Text1 Do-> stop Ensure that when you are finished, the connection is not red. Incomplete connections are in the color red. 8. Test the applet. The applet appears as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

129 Figure 135. Applet Designer: Animated redbook with nervous text 3.5 Net Objects ScriptBuilder 3.0 NetObjects ScriptBuilder provides you with a text-based, context-sensitive editor for files that contain common markup, scripting, and programming languages. NetObjects ScriptBuilder 3.0 is a script development environment for the Internet that offers a fast way to bring client and server side scripting to Web sites. It combines a powerful script editor and rich development tools with a visual, point-and-click environment that speeds script development. ScriptBuilder bridges the gap between Netscape, Microsoft, IBM, and Sun Microsystems Web scripting environments. It includes full support for Allaire Cold Fusion Markup Language (CFML), Dynamic HTML, ECMAScript, HTML, Java Server Pages (JSP), Java, Lotus LotusScript, Microsoft Active Server Pages (ASP), Microsoft Channel Definition Format (CDF), Microsoft Document Object Model (DOM), Microsoft JScript, Microsoft VBScript, Netscape JavaScript, Netscape LiveWire, Perl, and Wireless Markup Language (WML). With NetObjects ScriptBuilder, you can: Check your script syntax for errors Create reusable object-oriented script components Access local and Web-based language reference from within ScriptBuilder Customize the language reference using Extensible Markup Language (XML) Check your documents for browser compatibility Drag and drop language elements into your document Use Web-standard languages or languages other than Web-standard Quickly navigate to embedded functions and components Automate repetitive tasks Preview your documents internally or in the external browser of your choice WebSphere Studio tools 119

130 3.6 VisualAge for Java 3.0 Professional Edition VisualAge for Java Professional Edition provides you with a complete Java Integrated Development Environment (IDE) including a Java code editor, debugger, visual composition editor, class browser, and various wizards. VisualAge for Java Enterprise Edition is available separately from WebSphere Studio for even more Java development capabilities, including team support. WebSphere Studio integrates with VisualAge for Java Version 3.0 to provide quick navigation between the two products: When you use the Studio Wizards to develop servlets and JavaBeans, you can transfer them to VisualAge to extend their functions and maintain them there. When you develop new servlets and JavaBeans in VisualAge, you can bring them into Studio to use in the JavaBean Wizard or publish to your Web sites. When you modify components in VisualAge for Java, you can update the copies in the Studio project with the newer versions. In this case, we recommend that VisualAge for Java be your primary tool for maintaining these Java components. If you have your Studio project under a version-control system, you should use the same version-control system for VisualAge for Java. 120 Web Enabling AS/400 Applications with IBM WebSphere Studio

131 Chapter 4. Restoring the ABC Company Web site sample project This chapter explains how to enable the ABC Company Web site by restoring the WebSphere Studio archive file (ABCCompany.war) into WebSphere Studio. The following topics are discussed in detail: Creating the ABC Company project within WebSphere Studio based on the WebSphere Studio archive file (ABCCompany.war) Defining the AS/400 system as the publishing target system into WebSphere Studio Publishing the ABC Company Web site to the AS/400 system Surfing the ABC Company Web site ReadMe file Before attempting to restore the WebSphere Studio archive file (ABCCompany.war) and create the ABC Company Web site, you must follow the instructions on the ReadMe file that is package with the self-extracting file SG exe. Refer to Appendix A, Example programs on page 405, for more information on how to download the SG exe self-extracting file from the ITSO Web site. 4.1 Installing the download files At this time, we assume that you have already downloaded the SG exe self-extracting file, as explained in Appendix A, Example programs on page 405, for more information. You do not need a copy of Winzip program to install this compressed file since it is self extracting. However, if you prefer to browse the contents (for example, for security reasons), you need a copy of the Winzip program. You can get a demonstration copy from the Web, or use an unzip utility that supports long file names. To install the AS/400 save file and WebSphere Studio archive file, you should run the SG exe self-extracting file on a Windows 95, 98, or NT system from Windows Explorer or from the command prompt. Winzip asks you for the directory to which you want to extract the files. We suggest that you use the C:\Redbook directory, as described in Appendix A, Example programs on page 405. Then, it automatically creates a Code5634 sub-directory and places all the files into it. 4.2 Creating the WebSphere Studio project using the archive file In this section, we assume that you have already extracted the ABCCompany.war file. This is the WebSphere Studio archive file, which contains the ABC Company WebSphere Studio sample project. We create the project based on the archive file, so we can later create the Web site by publishing the project to an AS/400 server. Copyright IBM Corp

132 4.2.1 Restoring the project archive file Perform the following steps to restore the ABC Company Web site project from the WebSphere Studio archive file: 1. Start WebSphere Studio if it is not already started. 2. Select File->Open Archive and open the ABCCompany.war file. The Open Archive dialog appears with three tabs at the top. 3. On the Extract tab, select the Create new project and extract entire archive radio button as shown in Figure 136. Figure 136. Open Archive window: Extracting components 4. On the Destination tab, select the Custom locations radio button and specify the location where you want to extract the project components, for example C:\redbook\ABCCompany as shown in Figure 137. Figure 137. Open Archive window: Customizing the project location 5. On the Options tab, select the Use archived publishing targets radio button to preserve target definitions as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

133 Figure 138. Open Archive window: Preserving publishing targets 6. Click Extract. WebSphere Studio extracts the files and creates the ABC Company project as shown in Figure 139. Figure 139. WebSphere Studio ABC Company project Updating the ABC Company project files to use your AS/400 server The ABC company sample project was developed using our AS/400 server system, which we call AS20. You need to update the files to reflect your AS/400 system name. Perform the following tasks to update the project files: 1. Start WebSphere Studio if it is not already started. 2. Select the ABCCompany project. Then, select Edit->Find and Replace Text. Restoring the ABC Company Web site sample project 123

134 3. Replace the AS20 server with your AS/400 server (AS/400 system name) using the Find and Replace Text dialog box as shown in Figure 140. Figure 140. Studio Workbench: Find and Replace Text dialog box 4. Click Find Now. After finding the first AS20 occurrence, the Replace buttons are enabled. 5. Click the Replace All (AllFiles) button. 6. If you receive a Check Out message, as illustrated in Figure 141, click the Yes to All button. Also, click OK, Yes, oryes to All on any further messages. Figure 141. Studio Workbench: Check Out files message 7. When finished, click OK, and close the Find and Replace Text dialog box. 8. Right-click the ABCCompany project, and select the Check In option to check in all project files that have been checked out during the update process Creating an AS/400 user profile To run the servlets created by the Studio Wizards, you need to create an AS/400 user profile that matches the user ID and password in the ABC Company servlet files. On the AS/400 system, run the following OS/400 command: CRTUSRPRF USRPRF(REDBOOK) PASSWORD(HEAD4SEA) 124 Web Enabling AS/400 Applications with IBM WebSphere Studio

135 AS/400 user profile If your AS/400 system does not allow you to create a user profile with the USRPRF(REDBOOK) and PASSWORD(HEAD4SEA), for any reason, you can create it with any other values. However, you have to replace the ABC Company project files with the new userid and password values. Refer to 4.2.2, Updating the ABC Company project files to use your AS/400 server on page 123, for information on replacing text in the WebSphere Studio project files. 4.3 Setting up the AS/400 system to run the ABC Company Web site Now that the WebSphere Studio archive file has been restored, the next step is to deploy and run the ABC Company application on the AS/400 system. The objective of this section is to cover the deployment and packaging of the WebSphere Studio applications Publishing to the AS/400 system Once the WebSphere Studio application is ready and working on your client machine, you are ready to publish the project on your AS/400 system. Perform the following steps to publish the ABC Company project on your AS/400 system: 1. Map a network drive to the IFS of the AS/400 system. In this example, we map the I: drive to the root of the AS/400 IFS. \\youras400\root 2. Start WebSphere Studio, and open the ABCCompany project. 3. Select Project->Publishing Stage->Test. 4. Select View->Publishing. 5. Add the AS/400 server to the Test stage. Right-click on the Test stage icon. Select Insert->Server from the menu as shown in Figure 142. Figure 142. Inserting a server in the Test publishing stage 6. Enter the server name, youras400, andthetcp/ipportonwhichyou configured the WebSphere Application Server as illustrated in Figure 143 on page 126. After you add the server, you need to define its properties. Restoring the ABC Company Web site sample project 125

136 Figure 143. Inserting the AS/400 server in the Test publishing stage As shown in Figure 144, you now see the new server under the Test publishing stage. Figure 144. The Test publishing stage 7. To change the default server to your AS/400 system, right-click on the Test stage icon, and select Properties from the menu. Click the Advanced tab, and select the AS/400 server from the Default server drop-down list as illustrated in Figure 145. Figure 145. Changing the default server 126 Web Enabling AS/400 Applications with IBM WebSphere Studio

137 8. Close the Test Properties dialog by clicking OK. 9. Update the publishing targets for the AS/400 server by right-clicking on the AS/400 server icon and selecting Properties from the menu. When the Publishing Properties dialog appears, click the Define Publishing Targets button. When the publishing targets dialog appears as shown in Figure 146 on page 127, verify that the targets match the following names: html I:\QIBM\ProdData\IBMWEBAS\ servlet I:\QIBM\ProdData\IBMWEBAS\servlets Here, I: is a network drive assigned to the root of the AS/400 Integrated File System (IFS). Publishing target You may want to publish your HTML files to a separate directory. For this, youhavetocreateanhtmldirectoryunder \QIBM\ProdData\ibmwebas\html and then add a Pass directive in your HTTP configuration file. 10.If your targets do not match the path names in step 10, click the Browse button to navigate through the file system to find the files. Figure 146. AS/400 Publishing Targets 11.Click OK to close the Publishing Targets dialog. 12.Click OK to close the Publishing Properties dialog. 13.To set a default publishing target, select Tools->Publishing Options. Click the Advance tab, and select the AS/400 publishing target system from the Test drop-down list (Figure 147 on page 128). Restoring the ABC Company Web site sample project 127

138 Figure 147. Setting the AS/400 server as the default publishing server 14.Click OK to close the Publishing Options dialog. 15.To move the files to the publishing stage, select the ABCCompany project. Then select Edit->Set as Publishable->Yes from the pull-down menu to set the ABC Company files as publishable. This process moves all the project components under the Test->yourAS400 stage as illustrated in Figure 148. Figure 148. Setting the project files as publishable 16.From the publishing view, select the server Then, right-click, and select the Publish this server option. 128 Web Enabling AS/400 Applications with IBM WebSphere Studio

139 17.Several dialogs may appear. Select the default options on each and simply click OK, Yes, oryes to All ignoring the warnings. Publishing causes WebSphere Studio to copy all the files set as publishable to the publishing target (a Web servers directory structure). After this publishing process finishes, you receive a report as illustrated in Figure 149. Figure 149. Publishing report for the ABC Company project 18.Browse through the report and ensure that no files were found with errors before attempting to proceed. In case errors were found, you need to correct them, and then repeat the steps in this section. 19.Ensure that the WebSphere Application Server on AS/400 is up and running. 20.To test the publishing process, select the index.html file from the publishing view to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the ABC Company Welcome page appears as shown in Figure 150 on page 130. Restoring the ABC Company Web site sample project 129

140 Previewing Web sites The first time you call a generated Studio Wizards servlet, it will be slow. This is due to the fact that the JSP has to be compiled and the servlet has to connect to the database. Subsequent tries will be much faster. Important If you succeeded in publishing the ABC Company project to your AS/400 system, you should see the ABC Company Welcome page when previewing the index.html file, as shown in Figure 150. However, before attempting to browse other Web site pages, or use the Web site functionality, you must configure the WebSphere Application Server to use the LoginServlet servlet as described in 4.3.3, ABC Company Web site configuration on page 132. The LoginServlet validates the user ID input against an AS/400 database to determine if the user is a valid one. Figure 150. ABC Company Web site: Welcome page Packaging the WebSphere Studio application The objective of this section is to package the application so it can be distributed to different systems. The key consideration is how to keep the packaging simple. There are many ways of packaging the application. Here is a simple way to do it. 130 Web Enabling AS/400 Applications with IBM WebSphere Studio

141 Once the application is ready, deployed, and tested, you are ready for distribution. The challenge is to package the application in such a way that the distribution is easy. Perform the following steps to package the ABC Company application: 1. Create a customized publishing stage by selecting Project->Customize Publishing Stages. EnterDistribute as the stage name (Figure 151). Figure 151. Customize Publishing Stages 2. Click the Add button, and then click the OK button to close the Customized Publishing Stage window. 3. Select Project->Publishing Stage->Distribute. 4. To add a server to a publishing stage, right-click on the Distribute stage icon. Select Insert->Server from the menu, and then enter Export as the server name. Click OK. After you add the server, you need to define its properties. 5. Right-click on the Export server icon, and select Properties from the menu. When the Publishing Properties dialog appears, click the Define Publishing Targets button. The publishing targets dialog appears as shown in Figure 152. Enter the following paths as publishing targets: html x:\output\html servlet x:\output\servlets Here, x: is the drive where you want the files be located in your computer. Figure 152. Publishing Targets Restoring the ABC Company Web site sample project 131

142 6. Click OK twicetoreturntothestudioworkbenchwindow. 7. Publish the entire project by right-clicking on it and selecting Publish whole Project from the menu option. 8. Several dialogs may appear. Select the default options on each and simply click OK, Yes, oryes to All ignoring the warnings. Publishing causes WebSphere Studio to copy all the files set as publishable to the publishing target (a Web server directory structure). After this publishing process finishes, you receive a report as illustrated in Figure 149 on page Open the Windows Explorer. You should now see a folder named output which contains the HTML and servlets folders. 10.Compress the output folder to a.zip file. It is now ready for distribution. When you restore the files on the target system, make sure that you put the contents of the HTML and servlets folder in the appropriate publishing folder ABC Company Web site configuration This section discusses some of the configuration considerations for the ABC Company Web site. These considerations apply for any Web site development. To make the distribution of an application easier, you should externalize parameters. You can then change the parameters without changing the programs. In this application, we externalize the userid, password, database, and JDBC driver used by the application. This section also highlights the different ways in which you can configure the WebSphere Application Server to use a JDBC driver to access the AS/400 system. With the AS/400 system, you have two choices for a JDBC driver: the AS/400 Toolbox for Java driver or the native driver. The one to use depends on where you are running the WebSphere Application Server. If it is on the AS/400 system, use the native driver. Otherwise, use the AS/400 Toolbox for Java driver Soft coding the parameters and creating a servlet alias The objective of this section is to avoid hard-coding the connection related parameters. As discussed in Chapter 8, Creating the complete ABC Company Web site on page 361, the LoginServet servlet takes the user ID input and validates it against an AS/400 database to determine if the user is a valid one. We use JDBC to validate the user ID. To do this, there has to be a connection to the AS/400 system. To establish a connection, you need an AS/400 system user ID, password, URL, and the JDBC driver to use. There are various ways in which you can avoid hard-coding these values in the servlet. In this example, we use the WebSphere Application Server administration tool to define the parameters. We then access them in the servlet. By following this technique, you are more secure because you are not hard coding the parameters in the servlet. You can also change them based on the environment in which you deploy the application. In every servlet, there is a Init() method, which executes only one time during the lifetime of the servlet. It executes when the server loads the servlet. You can configure the server to load the servlet when the server starts or when a client first accesses the servlet. In the LoginServlet servlet, we use the getinitparameter() method to retrieve the parameters that we need for the connection to the AS/400 system. We use the 132 Web Enabling AS/400 Applications with IBM WebSphere Studio

143 WebSphere Application Server administration tool to configure the name of the servlet and the properties that it uses. Perform the following steps to configure the properties: 1. Open the WebSphere Application Server administration page on your browser by entering Enter the user ID and password to sign on. The default userid and password are Admin and Admin respectively. 2. Select Configuration under Servlets from the left-hand side frame. 3. Click Add to add a new servlet to the configuration. The Add New Servlet window appears as shown in Figure 153. Figure153. AddaNewServlet a. Enter login for the Servlet name. For the Servlet Class, enter session.loginservlet, which is the package and class name. When you use this technique, you assign the servlet a name. In this case, the name of the servlet is login. It points to the proper package and class name (session.loginservlet). When you execute this servlet, you execute login, not session.loginservlet. b. Click Add to add this servlet to the configuration. c. Verify that the servlet name appears in the Servlet Name list. d. Highlight it by selecting the servlet name under Servlet Name list. 4. Add the servlet properties to the servlet you created: a. Click the Add button in the Servlet Properties area of the administration page. b. Click the Name column of first row, and enter driver. Click the Value column, and enter com.ibm.as400.access.as400jdbcdriver. If you are running the application on the AS/400 system enter com.ibm.db2.jdbc.app.db2driver insteadtousethenativejdbcdriver. c. Click Enter to add this parameter to the properties list. d. Enter the following additional name and values parameters: Password: yourpassword User: youruserid URL: jdbc:as400://sysname//library Use jdbc:db2://sysname//library for the native JDBC driver. Restoring the ABC Company Web site sample project 133

144 Login: /loginindex.jsp Logout: /logout.jsp 5. Verify that the Loaded Now (YES) radiobuttonisselectedinordertoloadthe servlet. 6. Click Save to save the configuration. The servlet properties window appears as shown in Figure 154. Figure 154. Servlet properties page Here, apart from the normal parameters for the ABC Company site, we also have login and logout parameters, which point to the login and logout pages. By using this technique, we do not need to hard code the parameters. When running on the AS/400 system, the servlets.properties file on the AS/400 system is found in the QIBM\ProdData\IBMWebAS\properties\server\servlet\servletservice directory. The administration tool updates the servlets.properties file with the values we set. As a result of the entries made with the administration tool, the following entries are added to the servlets.properties file: servlet.login.code=session.loginservlet servlet.login.initargs=user=youruserid,password=yourpassword,url=jdbc:as400 :sysname/ library,driver=com.ibm.as400.access.as400jdbcdriver, login=/loginindex.jsp,logout=/logout.html The code used to retrieve the parameter in the LoginServlet is: String url = getinitparameter("url"); String userid = getinitparameter("user"); String password = getinitparameter("password"); String driver = getinitparameter("driver"); String login = getinitparameter("login"); String logout = getinitparameter("logout"); 134 Web Enabling AS/400 Applications with IBM WebSphere Studio

145 7. For the ABC Company application, we need two additional servlets added to the configuration file. They are: For session management purpose, we use check as the servlet name. This points to session.sessioncheckservlet. It has one property named loginpage and a value of /login.html. The following entries are added to the servlets.properties file: servlet.check.code=session.sessioncheckservlet servlet.check.initargs=loginpage=/login.html The second servlet is logout, which points to session.sessionlogoutservlet. It has a property named logoutpage with a value of /logout.html. The following entries are added to the servlets.properties file: servlet.logout.code=session.sessionlogoutservlet servlet.logout.initargs=logoutpage=/logout.html 8. Save the configuration and recheck to see if all the servlet names and their properties are saved and correct Using AS/400 Toolbox for Java to access the AS/400 database The objective of this section is to show how make classes from the AS/400 Toolbox for Java available to the WebSphere Application Server. Once you publish the application to the AS/400 system, the WebSphere Application Server needs to know how to locate all the classes it uses. Follow these steps to allow the AS/400 Toolbox for Java classes to be used: 1. Open the WebSphere Application Server administration page on your browser by entering: 2. Click Java Engine under Setup. The Java Engine page appears as shown in Figure 155. Figure 155. Java Engine page 3. Add the following path to the Application Server Classpath: /QIBM/ProdData/IBMWebAS/web/classes:/QIBM/ProdData/HTTP/Public/jt400/lib/jt 400.zip:/QIBM/ProdData/HTTP/Public/jt400/lib/x4j400.jar Restoring the ABC Company Web site sample project 135

146 /QIBM/ProdData/IBMWebAS/web/classes is the classpath entry for the WebSphere Application Server. It is added by default. /QIBM/ProdData/HTTP/Public/jt400/lib/jt400.zip is the classpath entry for the AS/400 Toolbox for Java. This is needed to tell the WebSphere Application Server where to look for the AS/400 Toolbox for Java classes. /QIBM/ProdData/HTTP/Public/jt400/lib/x4j400.jar is the classpath entry for the XML parser class files. This is required for using PCML calls. To avoid this, you can serialize the servlet that uses PCML calls. Note For the AS/400 system, the classpath has colons between the entries and not commas as in other platforms. As a result of this configuration, the following line is added to the bootstrap.properties file in the AS/400 IFS /QIBM/ProdData/ibmwebas/properties directory path: java.classpath=/qibm/proddata/ibmwebas/web/classes:/qibm/proddata/http/public/ jt400/lib/jt400.zip:/qibm/proddata/http/public/jt400/lib/x4j400.jar. Now, you are ready to run the ABC Company Web site application. At this point, all the required configuration is done. 136 Web Enabling AS/400 Applications with IBM WebSphere Studio

147 Chapter 5. Order Entry application This chapter presents the RPG Order Entry application example. This application is representative of a commercial application, although it does not include all of the necessary error handling that a business application requires. The chapter also introduces the application and specifies the database layout. In Chapter 6, Enabling the Order Entry application: Methodology on page 151, we convert the RPG Order Entry application to a Web-enabled application. The goal is to use the existing RPG application to service both the Web application and the host 5250 application. 5.1 Overview of the Order Entry application This section provides an overview of the application and a description of how the application database is used The ABC Company The ABC Company is a wholesale supplier with one warehouse and 10 sales districts. Each district serves 3,000 customers (30,000 total customers for the company). The warehouse maintains stock for the 100,000 items sold by the company. Figure 156 illustrates the company structure (warehouse, district, and customer). Figure 156. The company structure The ABC Company database The company runs its business with a database. This database is used in a mission critical, online transaction processing (OLTP) environment. The database includes tables with the following data: District information (next available order number, tax rate, and so on) Customer information (name, address, telephone number, and so on) Order information (date, time, shipper, and so on) Order line information (quantity, delivery date, and so on) Copyright IBM Corp

148 Item information (name, price, item ID, and so on) Stock information (quantity in stock, warehouse ID, and so on) A customer transaction A customer transaction occurs based on the following series of events: 1. Customers telephone one of the 10 district centers to place an order. 2. The district customer service representative answers the telephone, obtains the following information, and enters it into the application: Customer number Item numbers of the items the customer wants to order The quantity required for each item 3. The customer service representative may prompt for a list of customers or a list of parts. 4. The application then performs the following actions: a. Reads the customer last name, customer discount rate, and customer credit status from the Customer table (CSTMR). b. Reads the District table for the next available district order number. The next available district order number increases by one and is updated. c. Reads the item names, item prices, and item data for each item ordered by the customer from the Item table (ITEM). d. Checks if the quantity of ordered items is in stock by reading the quantity in the Stock table (STOCK). 5. When the order is accepted, the following actions occur: a. Inserts a new row into the Order table to reflect the creation of the new order (ORDERS). b. A new row is inserted into the Order Line table to reflect each item in the order. c. The quantity is reduced by the quantity ordered. d. A message is written to a data queue to initiate order printing Application flow The RPG Order Entry Application consists of the following components: Note To download the sample code used in this redbook, please refer to Appendix A, Example programs on page 405, for more information. ORDENTD (Parts Order Entry): Display file ORDENTR (Parts Order Entry): Main RPG processing program PRTORDERP (Parts Order Entry): Print file PRTORDERR (Print Orders): RPGserverjob SLTCUSTD (Select Customer): Displayfile SLTCUSTR (Select Customer): RPG SQL stored procedure SLTPARTD (Select Part): Display file SLTPARTR (Select Part): RPG stored procedure 138 Web Enabling AS/400 Applications with IBM WebSphere Studio

149 Each component is shown in the RPG Application flow in Figure 157. Figure 157. RPG application flow ORDENTR is the main RPG program. It is responsible for the main line processing. It calls two supporting RPG programs that are used to prompt for and select enduser input. They are SLTCUSTR, which handles selecting a customer, and SLTPARTR, which handles selecting part numbers. PRTODERR is an RPG program that handles printing customer orders. It reads order records that were placed on a data queue and prints them in a background job Customer transaction flow The following scenario walks through a customer transaction showing the application flow. By understanding the flow of the AS/400 application, you can understand the changes made to this application to support a graphical client Starting the application To start the application, the customer calls the main program from an AS/400 command line: CALL ORDENTR When the Order Entry application is started, the display shown in Figure 158 on page 140 appears. Order Entry application 139

150 Figure 158. Parts Order Entry When the Parts Order Entry display appears, the user has two options: Type in a customer number, and press the Enter key. End the program by pressing either F3 or F12. If the user does not know the customer number, they can press F4 to view a window containing a list of available customers. Figure 159. Select Customer The user presses F12 to remove the window and return to the initial panel, or they scroll through the items in the list until they find the customer they want. By 140 Web Enabling AS/400 Applications with IBM WebSphere Studio

151 typing a 1 in the option field and pressing the Enter key, the user indicates their choice. The selected customer is then returned to the initial panel (Figure 160). Figure 160. Parts Order Entry After selecting a customer from the list, or typing a valid customer number and pressing the Enter key, the customer details are shown and an order number is assigned. An additional prompt is displayed allowing the user to type a part number and quantity. If the user does not know the part number, they can press F4 to view a window containing a list of available parts (Figure 161 on page 142). Order Entry application 141

152 Figure 161. Select Part The user presses F12 to remove the window and return to the initial panel, or they scroll through the items in the list until they find the part they want. By typing a 1 in the option field and pressing the Enter key, they indicate their choice. The selected part is returned to the initial panel (Figure 162). Figure 162. Parts Order Entry After selecting a customer from the list, or typing a valid customer number and pressing the Enter key, the part and quantity ordered are added to the list section below the part entry fields (Figure 163). 142 Web Enabling AS/400 Applications with IBM WebSphere Studio

153 Figure 163. Parts Order Entry The user may type a 2 beside an entry in the list to change the order. When the Enter key is pressed, a window appears that allows the order line to be changed (Figure 164). Figure 164. Change Selected Order The user chooses to press F12 to cancel the change, press F4 to list the parts, or type a new part identifier or different quantity. Pressing the Enter key validates the part identifier and quantity. If valid, the order line is changed in the list and the window is closed. Order Entry application 143

154 Figure 165. Completed order In Figure 165, you see the quantity for Zoo Season Pass is changed to 3. When the order is complete, the user presses F6 to update the database. Then, an order is placed on the data queue for printing. Figure 166. Printed order 144 Web Enabling AS/400 Applications with IBM WebSphere Studio

155 The printed order (Figure 166) is created by a batch process. It shows the customer details and the items, quantities, and cost of the order Database table structure The ABC Company database has eight tables: District Customer Order Order Line Item Stock Warehouse History The relationship among these tables is shown in Figure 167. Figure 167. Table relationships Order Entry application database layout The sample application uses the following tables of the database: District Customer Order Order line Stock Item (catalog) The following tables describe, in detail, the layout of the database. Order Entry application 145

156 Table 2. District table layout (Dstrct) Field name Real name Type Length DID District ID Decimal 3 DWID Warehouse ID Character 4 DNAME District Name Character 10 DADDR1 Address Line 1 Character 20 DADDR2 Address Line 2 Character 20 DCITY City Character 20 DSTATE State Character 2 DZIP Zip Code Character 10 DTAX Tax Decimal 5 DYTD Year to Date Balance Decimal 13 DNXTOR Next Order Number Decimal 9 Primary Key: DID and DWID Table 3. Customer table layout (CSTMR) Field name Real name Type Length CID Customer ID Character 4 CDID District ID Decimal 3 CWID Warehouse ID Character 4 CFIRST First Name Character 16 CINIT Middle Initials Character 2 CLAST Last Name Character 16 CADDR1 Address Line 1 Character 20 CCREDT Credit Status Character 2 CADDR2 Address Line 2 Character 20 CDCT Discount Decimal 5 CCITY City Character 20 CSTATE State Character 2 CZIP Zip Code Character 10 CPHONE Phone Number Character 16 CBAL Balance Decimal 7 CCRDLM Credit Limit Decimal 7 CYTD Year to Date Decimal 13 CPAYCNT Payment Decimal Web Enabling AS/400 Applications with IBM WebSphere Studio

157 Field name Real name Type Length CDELCNT Delivery Qty Decimal 5 CLTIME Time of Last Order Numeric 6 CDATA Customer Information Character 500 Primary Key: CID, CDID, and CWID Table 4. Order table layout (ORDERS) Field name Real name Type Length OWID Warehouse ID Character 4 ODID District ID Decimal 3 OCID Customer ID Character 4 OID Order ID Decimal 9 OENTDT Order Date Numeric 8 OENTTM Order Time Numeric 6 OCARID Carrier Number Character 2 OLINES Number of Order Lines Decimal 3 OLOCAL Local Decimal 1 PrimaryKey:OWID,ODID,andOID Table 5. Order Line table layout (ORDLIN) Field name Real name Type Length OID Order ID Decimal 9 ODID District ID Decimal 3 OWID Warehouse ID Character 4 OLNBR Order Line Number Decimal 3 OLSPWH Supply Warehouse Character 4 OLIID Item ID Character 6 OLQTY Quantity Ordered Numeric 3 OLAMNT Amount Numeric 7 OLDLVD Delivery Date Numeric 6 OLDSTI District Information Character 24 PrimaryKey:OLWID,OLDID,OLOID,andOLNBR Order Entry application 147

158 Table 6. Item table layout (ITEM) Field name Real name Type Length IID Item ID Character 6 INAME Item Name Character 24 IPRICE Price Decimal 5 IDATA Item Information Character 50 Primary Key: IID Table 7. Stock table layout (Stock) Field name Real name Type Length STWID Warehouse ID Character 4 STIID Item ID Character 6 STQTY Quantity in Stock Decimal 5 STDI01 District Information Character 24 STDI02 District Information Character 24 STDI03 District Information Character 24 STDI04 District Information Character 24 STDI05 District Information Character 24 STDI06 District Information Character 24 STDI07 District Information Character 24 STDI08 District Information Character 24 STDI09 District Information Character 24 STDI10 District Information Character 24 STYTD Year to Date Decimal 9 STORDERS Number of orders Decimal 5 STREMORD Number of remote orders Decimal 5 STDATA Item Information Character 50 Primary Key: STWID and STIID Database terminology This redbook concentrates on the use of the AS/400 system as a database server in a client/server environment. In some cases, we use SQL to access the AS/400 database. In other cases, we use native database access. 148 Web Enabling AS/400 Applications with IBM WebSphere Studio

159 The terminology used for database access is different in both cases. In Table 8, you find the correspondence between the different terms. Table 8. Database terminology AS/400 native SQL Library Physical File Field Record Logical File Collection Table Column Row View or Index Order Entry application 149

160 150 Web Enabling AS/400 Applications with IBM WebSphere Studio

161 Chapter 6. Enabling the Order Entry application: Methodology This chapter walks through the Web-enablement methodology cycle of a simple AS/400 order entry application, as described in Chapter 5, Order Entry application on page 137. Many, but not all, tools available in the IBM WebSphere Studio are discussed. 6.1 Identifying the AS/400 application to Web-enable The idea behind Web enabling is identifying portions of a company s business operations and functions, which could be off loaded to clients or customers. Some primary examples are catalog browsing, inventory stock status lookups, order entry, customer service functions. In our example scenario, we identify a call center model. We offload the functions of answering the phone, order entry, and order acceptance from the call center clerks. We eliminate the phone calls and allow the customers to perform catalog browsing, order entry and order acceptance, order status look up all by themselves. However, this does not mean that we eliminate the call center all together. Even though the tasks of the call center could be accomplished by the end users (customers, clients), a scaled-down version of the call center is still needed to accommodate the end users who are not Web or computer savvy Primary users of the Web application Prior to the development of the Web site, primary users need to be identified. Knowledge of who the primary users are guides the design and development processes. In our scenario, primary users are: Customers/clients who use the call center to: Place orders Browse products catalog to check availability and pricing Check order status Administrator to (these function are not implemented in the ABC Company sample project): Validate new Web users Review or Print various order reports Delete Web user profiles Reset passwords Identifying issues and assumptions A Web site can certainly alter a company s operations, business processes, and so forth. To foresee the changes and analyze the impact, issues and assumptions need to be identified: Issues (not in any particular order): Since Web users will trigger the creation of their Web profiles (not AS/400 user profiles) and customer records, the validation function becomes very important. Copyright IBM Corp

162 Security is another concern, which should be include authentication and encryption. Performance evaluations should become a standard practice to accommodate the Web traffic loads. Assumptions (not in any particular order): Business logic is preserved on AS/400 server. Presentation logic is put on the Web. Existing customers have to be setup as Web users. Validation and error handling should be strong to avoid the bad data getting into the enterprise database. Refer to 8.6, Heading towards e-commerce on page 400, for more in depth discussion on e-commerce Analysis of the AS/400 application: Business and presentation logic The idea behind the separation of business and presentation logic is to preserve current databases and application programs that are running on the AS/400 server. Application programs and databases have specific business rules built in. The AS/400 server is a secure, reliable, and stable platform. We cannot afford to rewrite it all, for example, using Enterprise JavaBeans (EJBs), because of the cost, risk, and other factors. Some portions of the application on the AS/400 server may not need to be rewritten because they are efficient, fast, and proven. For the ABC company, the order commitment, inventory management, and customer record validation logic are preserved within the AS/400 database and applications. The RPG Order Entry program was changed to allow the separation of the presentation from business logic. Refer to 7.6, Changes to the Host Order Entry application on page 343, for details on a separation presentation from business logic. 6.2 Web-site design When it comes to working with presenting content on the Internet, there are many considerations a designer or developer must take into account. You need to remember who your target audience is. Many people design Web sites that are difficult to navigate and use. A key concept to remember when developing an Internet Web site is to make the content fit the Web site and not the Web site fit the content. Many people decide the entire content of the Web site first and then create a design and navigation to suit. A better way to create a Web site is to decide the objective of the Web site, the key areas of the site, and how to navigate between all these pages. Once this is decided, it is easy to fill the content in on each page. Figure 168 shows the navigation we use in the ABC Company Web site. 152 Web Enabling AS/400 Applications with IBM WebSphere Studio

163 Figure 168. Complete Web site navigation Dividing the Web site into subsites based on functionality Once you decide the navigation between the various sections of the Web site, it becomes clear that there are subsites that make the generation of the Web site a lot easier. If you look at the initial design, you see how the flow of the site between the static front pages and the dynamic interactive pages has a one-way path. This is a good place to break the site into subsites. All of the front pages that are static can be the static subsite and all the interactive pages can be subsite two. If you look closer at the interactive site, you see some different areas of functionality. You have a shopping cart, catalog, order status, and order processing. Each of these should be broken down into subsites since you know that there is some sort of code generation that needs to go on inside these sites. If you break them into subsites, testing each section becomes significantly easier Static HTML pages The static pages should contain all the information about the company. It is important to remember for the user that has come to this Web site for the first time and has no idea who the company is. The pages that would make up this subsiteareshowninfigure168: Welcome About Us History Catalog Login Login Error Logout NewUser Login and session management Login and session management is important to verify if the user is allowed in the dynamic Web site and so you can use their username to retrieve their customer Enabling the Order Entry application: Methodology 153

164 ID from the database. Once you have their customer ID, you can get all information about this user, such as what they have in their shopping cart. After the user has logged in, you also generate a dynamic session ID that is assigned and maintained in the AS/400 WebSphere Application Server. The session that the user gets allocated is tested on every page for its existence. This is important because if a user accesses a page that requires a customer ID and they have not logged in, errors appear since you have no way to identify this user. The session test looks to see if the user has a session and will then redirect theusertotheloginpageiftheyarerequiredtologin New users Within the existing order entry application users must have user profiles defined on the AS/400 server. Web users are not going to have user profiles setup on the AS/400 server, yet you need to authenticate them and provide some sort of security. There are many different ways to handle the issue. Our solution is to create a table on the AS/400 server to hold Web users records with Web-related information and a link to their customer ID. When a new Web user wants to access the Web site, they fill out a form with their personal information and specify their login ID and password. When they click the Submit button, their records are added to the existing customer table and to the Web user table. Once a new user has been created, the user is given the acknowledgement. They can then log straight into the dynamic pages without having to provide their username and password again. There is some information that the user will not provide. For example, the user will not be able to give their credit limit or discount. This means that any new user that is generated will be flagged as having a new account. The user can order whatever they like from the Web site. However, before the order is packed and shipped, their account needs to be validated. You can also take extended information from the user that, until now, was not needed within the customer database. The main piece of new information that you require is the users . If you expect the customer to deal with you over the Internet, it would be better to contact them over the Internet providing the information is not confidential Catalog The catalog subsite allows the user to view the catalog and find all products that ABC Company has to offer. It is important for the user to access the catalog regardless of being a registered member. If you look back at the subsite layout on Figure 168 on page 153, you see that the catalog can be accessed in two places. If a user accesses the catalog in the static site area, they have gone there simply to view the products that are offered with absolutely no obligation to purchase. The second place the catalog can be found is inside the dynamic site section. This version of the catalog allows the user to view all products on offer from the ABC Company and to select a product from the catalog to add to the catalog. You can only offer this to the Web shopper since you only know their customer ID after they have logged in. Another key feature of the catalog is to allow the user to search for items meeting a certain criteria. The search requirement we added to our demonstration application allows the user to select the price range of an item. We could easily allow the user to search for items based on a description or even availability. The 154 Web Enabling AS/400 Applications with IBM WebSphere Studio

165 other way we present the catalog is to display all items in alphabetical order. This is only practical when the company has no more than 100 products. You need to remember that when a user views the entire catalog they need to wait for the catalog to download to their browser. If the company has 10,000 products, the user needs to wait some time to view the catalog and lose interest in the site Shopping cart The shopping cart subsite allows the user to view and edit all the items they have selected to date. The shopping cart has its own table on the AS/400 system that stores all the products that the user wants to purchase. There are techniques in which the shopping cart could be stored besides in a table. You could easily use beans that are bound to the WebSphere Application Server. However, if you have 15 concurrent users each with 30 items in their shopping cart, performance will suffer and again cause your Web customers to lose interest. The downside to maintaining a table for the shopping cart is that it is not tightly integrated with the WebSphere Application Server, and you need to add logic to look at how relevant their shopping cart is. For example, if the user shopped with you two years ago and did not purchase the contents of their shopping cart, they will see old information and possibly even products that do not exist any more Order purchase The order purchasing subsite is where the integration into the RPG application happens. Until this point, you have added layers around the application so that you can accumulate the information about the products the user wants to purchase. Once they are satisfied, you can pass this information to the RPG application as parameters. You cannot partially process an order since the user progresses through the Web site. The order purchase passes the contents of the shopping cart to the RPG application. Once the RPG application is called and the order has been created, the contents of the shopping cart are deleted. Once the user has ordered those items, there is no need to maintain the cart Order status It is good for a user to see what is happening with their order. You have allowed your user to order your products over the Web. The last thing you need is for them to call you to find out what is happening with their product. If the customer calls you because they cannot find their order status on your Web site, you have failed in using the Internet e-commerce, e-business solution. The order status subsite also needs to be behind the login page for the same reason as the other subsites. You need to know the users customer ID so you can retrieve the correct information Subsite development and unit testing Now that we have established what a subsite is, we explore the added benefit of having a subsite. Subsites can be distributed among Web site developers and there is no concern for overlapping work. WebSphere Studio supports multiple people working on the one project. However, if, in the early stages, two people share the work on a single page, the process becomes slow and inefficient. The only time multiple people should work on the same pages is when the site is being finalized and ready for deployment. This optimizes the work performed and produces results faster. Enabling the Order Entry application: Methodology 155

166 When each of the subsites are created, they can be tested individually. Chapter 7, ABC Company Web site design and development on page 157, shows how the WebSphere Studio Wizards are used to generate the dynamic pages and a static page is produced. The static page uses a static parameter given by you and you can fully test to make sure the results are as you expect Tying it all together After the subsites have been generated, you can tie the entire Web site together. The first thing you need to look at is what parameters are passed to each of the pages. This can be determined by looking at the test HTML page. You can call the servlets that have been generated by any page, provided you pass the parameters that are expected. By looking at the test page, you can clearly see what these parameters are. If there are four fields on your test page, you need to submit for parameters to the servlet that is called. This is discussed in further detail in Chapter 7, ABC Company Web site design and development on page 157. The final step to tying it all together is placing the session checking servlet on every page that is inside the dynamic Web site. This needs to be there to ensure that any parameter that are required by that page are instantiated before that page is called Integration testing Now that the entire site has been created, some extensive testing should be done. It is important to remember that this is being presented to people that you want to do business with you. If the Web site does not work correctly, people will be disheartened and not trade with you in this manner. Spend some time going though the full process and testing everything. Treat the entire Web site as an application and put it through the same testing regime through which you would put any application you created on the AS/400 system. 6.3 Summary You should consider these issues during the Web site design: Keep site message and appearance consistent and familiar. Use content elements wisely. Test as many different likely client scenarios as possible. In Chapter 7, ABC Company Web site design and development, we cover design and development of the building blocks, which we call subsites, forthe ABC Company Web site. We heavily rely on the WebSphere Studio Wizards, which generate queries, servlets, beans, HTML pages, and Java Server Pages (JSPs), which, in turn, provide most of the functionality required. 156 Web Enabling AS/400 Applications with IBM WebSphere Studio

167 Chapter 7. ABC Company Web site design and development This chapter covers the design and development of the building blocks, which we call subsites, for the ABC Web site. We heavily rely on the WebSphere Studio Wizards, which generate queries, servlets, beans, HTML pages, and JavaServer Pages (JSPs), which, in turn, provide most of the functionality required. Except login and session management subsites, the development process, for the most part, follows this series of steps: 1. Analyze the requirements for the particular subsite to determine the functionality and flow. For example, for new user subsite, plan to determine the inputs, database access, validation, confirmation pages, and so forth. 2. Use the SQL WebSphere Studio SQL Wizard to generate the query to select, update, delete, or insert database records. 3. Use the WebSphere Studio Database Wizard to generate HTML pages, servlet, bean, and JSPs. 4. Modify or add the code inside the servlet or the bean where necessary. For example, for Order purchase subsite, you may indicate Added code to call the AS/400 application program. 5. Change the format of the resulting pages where necessary. 6. Create a self-contained subsite, consequently making it easier to integrate it intothecompleteabcwebsite. 7. Unit test the subsite. The WebSphere Studio tools we use should be familiar to you if you read and ran the examples described in Chapter 3, WebSphere Studio tools on page 23. To avoid confusion, we explain each step during the development of every subsite. It may seem redundant. However, we describe the steps we took to deliver the complete and functional ABC Company s Web site. Before testing your work for the individual subsites, be sure to define publishing targets to the AS/400 server. You can find instructions on setting up publishing targets in 4.3.1, Publishing to the AS/400 system on page 125. You also need to download and restore the AS/400 library (APILIB), which contains database tables and program objects. Refer to Appendix A, Example programs on page 405, for detailed instructions. You can download the resulting project of the complete ABC Company Web site in the archive form and set it up as a reference. To download, restore, and create WebSphere Studio ABC Company project, corresponding AS/400 APILIB library, and to publish the ABC Company Web site, follow instructions in Table 9. Table 9. Setting up ABC Company Web site Information source Section Appendix A, Example programs on page 405. ABC Company Web site sample project - Readme file Information Downloading and running the self extracting zip file. Restoring AS/400 library from the save file. Copyright IBM Corp

168 Information source Chapter 4, Restoring the ABC Company Web site sample project on page 121. Section 4.3.1, Publishing to the AS/400 system on page 125. Section 4.3.3, ABC Company Web site configuration on page 132. Information Creating WebSphere Studio project based on the archive file provided in the download. Defining publishing targets to the AS/400 server. Registering specific servlets in the WebSphere Application Server on the AS/400 server. 7.1 Login and session management Login and session management are key features to all e-commerce and e-business Web sites. It is necessary that you track the user across the site and maintain session information Creating the login servlet The following steps are required for using the WebSphere Studio to create a servlet to validate and login a user Flow of the login servlet First, you need to establish the login process: 1. The user goes to the login page. 2. The user enters a user name and password. 3. The user name and password are checked against the Web user table. 4. If the user name and password are valid, test if they have a session. 5. If they have a session, do not allocate one. They will maintain all session objects. 6. If they do not have a session, allocate a session. 7. If the user name does not exist, redirect the user to the new user page. 8. If the user name exists, but the password is incorrect, redirect the user to the login page Using the WebSphere Studio servlet template WebSphere Studio has custom templates of servlets. These were discussed in 3.3.3, Creating a page template on page 102. The servlet template has been setup to handle what to do on both a post and a get of a form. If you wanted to secure the servlet for one method, only you could move all the code from the performtask() method to either the dopost() or doget() method. For this example, we leave the code in the performtask() method. You need to add to the template the package to which this servlet will belong. You also need to add what the servlet will implement. You can also fill in all the custom comments and the servlet information method. 158 Web Enabling AS/400 Applications with IBM WebSphere Studio

169 Getting the parameters The first few lines of code in the performtask() method should get parameters that the user enters and also parameters that exist inside the WebSphere Application Server. The WebSphere Application Server parameters relate to where you want to redirect the user to under various circumstances and also where the database is and what it is called. By implementing these as softcoded parameters, you can change them at any time without having to recompile the Java source file. This is a useful technique especially if you are distributing your source code to everybody that uses your Internet application Validating the user name and password Now you have the parameters you need to test the user name and password against the Web user table on the AS/400 system. The following code does this: pstmt = con.preparestatement("select PWD,WCID FROM WEBUSRID.WEBUSRDB WHERE LOGIN_NAME =? "); pstmt.setstring(1, userid); rs = pstmt.executequery(); Normally, password-capable input fields are masked with ******* to protect the password value from being seen by someone other than the primary user. Double-click on the password input field to open the Attribute dialog box. In the Input Type section, select the Password radio button, and click OK Creating the session The next step is to create a session for this user. You can then bind information to this user s session and carry it across the entire site wherever the user goes. If you set the session to false, it gets the session based on the session cookie that the user has. If it is set to true, a session is created for the user. On the first login page, you can create a new session. But, what if the user was here five minutes ago and their browser crashed? All of the information will be lost if you blindly give them a new session. The best way to generate a session at login is with the following code: HttpSession session = request.getsession(true); Instantiating the custid bean Now that the user has been validated and has a session, you can instantiate the customer ID bean and bind it to the session you allocated to this user. Beans are the cleanest way to get information from a servlet to a JSP. By instantiating the bean, you can get the custid bean into your pages at any point after login. The only time you will lose this information is when the session expires. The code to instantiate the bean is given shown here: session.putvalue("custidbean", custidbean); session.putvalue("logon.isdone", "y"); Redirecting users Once you have identified the user as being valid or invalid, you can determine where to send them. You can redirect them using the send redirect method, but be careful of using hardcoded parameters here. If you use hardcoded parameters and change the structure of the Web site, you have to modify this servlet and recompile. It is easiest to use hardcoded parameters in the testing stages. You should redirect the user to the appropriate place depending on how they went in the login. The code to do this is shown here: ABC Company Web site design and development 159

170 response.sendredirect(loginindex); The code to redirect users if invalid login information provided is: response.sendredirect(loginerror); Finishing the servlet You now have all the pieces to complete this servlet. You also need to add exception handling. You need this to send the information to the users Web browser. The final code for the login servlet is given here: // // Copyright 19xx Your Company // // Owner: Your Name // // Class: JavaServlet // // Uncomment the next line if you want your Servlet in a package. package session; import com.ibm.servlet.*; import com.ibm.webtools.runtime.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import com.ibm.as400.access.*; import java.util.*; /** * JavaDoc comment for this servlet */ public class LoginServlet extends javax.servlet.http.httpservlet { /* **************************************************************************** * Returns a string that contains information about the servlet * The servlet information */ public java.lang.string getservletinfo() { return "This servlet matches a username and password to our web database."; } /* **************************************************************************** * Process incoming HTTP GET requests * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void doget(javax.servlet.http.httpservletrequest request, javax.servlet.http.httpservletresponse response) { performtask(request,response); } /* **************************************************************************** * Process incoming HTTP POST requests * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void dopost(javax.servlet.http.httpservletrequest request, javax.servlet.http.httpservletresponse response) { performtask(request,response); } /* **************************************************************************** 160 Web Enabling AS/400 Applications with IBM WebSphere Studio

171 * Process incoming requests for information * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void performtask(javax.servlet.http.httpservletrequest request, javax.servlet.http.httpservletresponse response) { //Declaration of variables Connection con = null; PreparedStatement pstmt = null; ResultSet rs = null; //Reterive the parameters from the servlet.properties file String dburl = getinitparameter("url"); String ProfId = getinitparameter("user"); String ProfPwd = getinitparameter("password"); String driver = getinitparameter("driver"); String logout = getinitparameter("logout"); String loginindex = getinitparameter("login"); String loginerror = getinitparameter("loginerrorpage"); // Get the user input values String userid = request.getparametervalues("username")[0]; String password = request.getparametervalues("password")[0]; try { //Get the Connection to the AS/400 Database Class.forName(driver); con = DriverManager.getConnection(dburl,ProfId,ProfPwd); //Create a Statement object pstmt = con.preparestatement("select PWD,WCID FROM APILIB.WEBUSRDB WHERE LOGIN_NAME =? "); pstmt.setstring(1, userid); // instantiate the beans and store them so they can be accessed by the called page ABC_Company.CustIDBean custidbean = null; custidbean = (ABC_Company.CustIDBean) java.beans.beans.instantiate(getclass().getclassloader(), "ABC_Company.CustIDBean"); //Execute the SQL query and get the resultset rs = pstmt.executequery(); if (rs.next ()) { if (rs.wasnull()) { //User does not exist, redirect the user to the logout page response.sendredirect(loginerror); } else { String dpwd = rs.getstring("pwd"); String dcid = rs.getstring("wcid"); // Compare the password with that in the database if ((password).compareto(dpwd.trim()) == 0) { //If the password entered by user is correct then create a session HttpSession session = request.getsession(true); // Assign the customer id value to the session as a parameter to be used in future session.putvalue("custidbean", custidbean); session.putvalue("logon.isdone", "y"); custidbean.setcustid(dcid); //send the user to the page after the login response.sendredirect(loginindex); } else { //Password failure - redirect the user to the logout page response.sendredirect(loginerror); } } } else // rs.next if end block { //User does not exist, redirect the user to the logout page response.sendredirect(loginerror); ABC Company Web site design and development 161

172 } // close the statement and the connection pstmt.close(); con.close(); } catch (Exception e) { } } } Building the custid bean We already been discussed how important it is to have the customer ID wherever the user goes after logging in. The bean can be generated from the template in a similar fashion as we did with the servlet. The bean becomes very simple. We need one property called custid, a getter for custid, and a setter for custid. The final code looks like the following example: package session; import com.ibm.webtools.runtime.*; import java.io.*; public class CustIDBean extends java.lang.object { protected java.lang.string custid = null; public java.lang.string getcustid() { } return custid; /* **************************************************************************** * Set method for the custid property value the new value for the custid property */ public void setcustid(java.lang.string value) { } } this.custid = value; Building a session management servlet The key feature of developing the session management servlet is to keep it simple. The process of session management is: 1. Check if the user has a session. 2. If a session exists, display the page. 3. If a session does not exist, redirect the user to the login page. This technique works really well. However, if a user takes a long time browsing the Web site, the session can time out and they will be redirected back to the login page. The user may be confused but, because we have maintained the shopping cart on the AS/400 system in a table, the information will not be lost. 162 Web Enabling AS/400 Applications with IBM WebSphere Studio

173 The code for this is identical to the login servlet. First, you do a create session with the parameter being false. You then test the session that you created. If the session results in being Null, the user has not been allocated and you redirect them to the login page. If the result is not Null, the user must have a valid session. The final step is to figure out where to send the user depending on their session status. If you allow them on the page, you need to finish the servlet with the print writer method so the rest of the page will be displayed. If they are not allowed to be there, they will be redirected. The redirection parameter should come from the variables inside the WebSphere Application Server as discussed above. The code for the session management servlet looks like this example: // // Copyright 19xx Your Company // // Owner: Your Name // // Class: JavaServlet // // Uncomment the next line if you want your Servlet in a package. package session; import com.ibm.servlet.*; import com.ibm.webtools.runtime.*; import java.io.*; import javax.servlet.*; import javax.servlet.http.*; import java.sql.*; import com.ibm.as400.access.*; import java.util.*; /** * JavaDoc comment for this servlet */ public class SessionCheckServlet extends javax.servlet.http.httpservlet { /* **************************************************************************** * Returns a string that contains information about the servlet * The servlet information */ public java.lang.string getservletinfo() { return "some useful information about the servlet goes here"; } /* **************************************************************************** * Process incoming HTTP GET requests * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void doget(javax.servlet.http.httpservletrequest request, javax.servlet.http.httpservletresponse response) throws ServletException, IOException { performtask(request,response); } /* **************************************************************************** * Process incoming HTTP POST requests * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void dopost(javax.servlet.http.httpservletrequest request, javax.servlet.http.httpservletresponse response) throws ServletException, IOException { performtask(request,response); ABC Company Web site design and development 163

174 } /* **************************************************************************** * Process incoming requests for information * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void performtask(javax.servlet.http.httpservletrequest request, javax.servlet.http.httpservletresponse response) throws ServletException, IOException { String loginpage = getinitparameter("loginpage"); try { // Step 1: Get the Session object HttpSession session = request.getsession(false); Object done = session.getvalue("logon.isdone"); if ( done == null) { response.sendredirect(loginpage); } else { PrintWriter out = response.getwriter(); } } catch (Exception e) { PrintWriter out = response.getwriter(); response.sendredirect(loginpage); } } } 7.2 Creating the new users subsite This section covers the development of the new users subsite. To browse the catalog of ABC products, or to place an order with the ABC Company, you need a Web user profile. If a person accessing ABC s Web site does not have a login ID, they can fill out a form. Based on the information entered, customer and Web user records are created. Web user profile is not to be confused with the OS/400 user profile. Ordinary Web users (not the administrator) do not need an OS/400 user profile. AS/400 database access is accomplished via one dedicated user profile, which is setup on the AS/400 system. The creation of the new users subsite requires development efforts within WebSphere Studio and on the AS/400 server as well New users: Development on the AS/400 server This section covers development efforts on the AS/400 server to support the creation of new Web users and creation of Web user profiles for the existing customers. Create a new table (physical file) on the AS/400 server to store and authenticate Web users and to link a Web user to a customer number within an existing AS/400 application. Table creation can be accomplished using the DDS method or an SQL statement, depending on your preference. We used the SQL method to create the WEBUSRDB table by following these steps: 164 Web Enabling AS/400 Applications with IBM WebSphere Studio

175 1. Issue the Start SQL (strsql) command on an AS/400 command line to start an SQL session. 2. Issue the following SQL statement: CREATE TABLE MYLIB/WEBUSRDB (LOGIN_NAME CHAR ( 10) NOT NULL WITH DEFAULT PRIMARY KEY, PWD CHAR ( 10) NOT NULL WITH DEFAULT, WCID CHAR ( 4) NOT NULL WITH DEFAULT UNIQUE, CHAR ( 25) NOT NULL WITH DEFAULT, VLDTED NUMERIC (1 ) NOT NULL WITH DEFAULT 0, LOGGEDIN NUMERIC (1 ) NOT NULL WITH DEFAULT 0, DATE DATE NOT NULL WITH DEFAULT, TIME TIME NOT NULL WITH DEFAULT) Table 10 describes the newly created WEBUSRDB physical file. Table 10. Web user table layout (WEBUSRDB) Field name Field description Type Length Default value LOGIN_NAME Web user login Character 10 None PWD Web user password Character 10 None WCID Customer ID (link to Customer ID in CSTMR table) Character 4 None address Character 25 None VLDTED Record Validated Flag Numeric means no LOGGEDIN User is logged in flag Numeric means no DATE Record created date Date 10 Current TIME Record created time Time 8 Current Primary key: LOGIN_NAME Access to the Catalog, Order Purchase, Order Status, and Shopping Cart pages is granted only if users properly login into the Registered Users Area of the ABC Web site. Login is successful if and only if the user specifies the login ID and password, which exist in the WEBUSRDB table. There are two ways in which the records may be created (inserted) in the WEBUSRDB table: New users supply their personal information via the Web. Based on the information entered, the WEBUSRDB table record and customer record in CSTMR table are created. An application program is written on the AS/400 server to create records in the WEBUSRDB table for existing customers in the CSTMR table. The program has to generate login IDs and passwords. Login IDs and passwords then have to be communicated to the Web users. In this redbook, we only cover the creation of the new Web user records via the Web. Developing the program to generate WEBUSRDB table records for the existing customers is a straight forward and trivial process, so we did not include it in the scope of this redbook. ABC Company Web site design and development 165

176 7.2.2 New users: Development using WebSphere Studio tools To develop the new user subsite functionality, we use WebSphere Studio Wizards and WebSphere Page Designer tools. To completely achieve desired functionality, we will alter wizard generated servlets, JSPs, and HTML files. The following list is a conceptual representation for the steps to creating a new Web user: 1. Obtain user information over the Web, such as, name, address, desired login name, password, and so forth. 2. Calculate the next Customer ID to be assigned to the new Web user. 3. Insert the customer record into the CSTMR table with user-supplied information and the Customer ID field equal to the result from step Insert the Web user record into the WEBUSRDB table with user-supplied information and the Customer ID field being equal to the result from step 2. Hint The key to creating a Web user profile is getting the information from the user and calculating the new customer number. The CSTMR table holds most of the information elements for the user to enter. WEBUSRDB records are the links between the Web user login ID and the customer ID. We generate the input HTML form based on the CSTMR table. You need to create a new WebSphere Studio project to package all the HTML, servlet, JSPs, and SQL files, which will be created during the process. Follow these steps: 1. On your PC, create a folder named subsites wherever your designated development area (drive) is, for example: c:\subsites. Replace c with the workstation drive on which you want to create the project. 2. Start WebSphere Studio if it is not already started. 3. Create a new project by selecting File->New Project from the pull-down menu: a. Type NewUser for the project name. b. Type drive:\subsites\newuser for the project folder. The entries shown in the Figure 169 should resemble your entries. 166 Web Enabling AS/400 Applications with IBM WebSphere Studio

177 Figure 169. New Project dialog box 3. Click OK. WebSphere Studio creates the folder \subsites\newuser and the project file called NewUser.wao. Within the project WebSphere Studio also creates the servlet folder, as illustrated in Figure 170. Figure 170. NewUser.wao project To accomplish the task of creating a Web user and to mostly rely on WebSphere Studio Wizards, follow these steps: 1. Create INSERT SQL for the CSTMR table using WebSphere Studio SQL Wizard. 2. Create an input HTML form for the user to enter personal information to be inserted in to the CSTMR database table. 3. Create a servlet and the DB access bean to update the CSTMR database table on the AS/400 system. ABC Company Web site design and development 167

178 4. Create resulting JavaServer Pages (JSPs) to provide feedback to the user on the updating CSTMR table. Note on steps 2 through 4 Steps 2 through 4 are accomplished using WebSphere Studio Database Wizard. The HTML input form, a servlet, and resulting JSPs will be generated all at the same time based on the SQL file created in step Create SELECT SQL CSTMR table, using WebSphere Studio SQL Wizard, to find the highest customer ID used in order to calculate the next available customer number. 6. Create a servlet and the DB access bean to select the highest customer ID from the CSTMR database table on AS/400 system using WebSphere Studio Database Wizard. 7. Create INSERT SQL for the WEBUSRDB table, using WebSphere Studio SQL Wizard. 8. Create an input HTML form for the user to enter personal information to be inserted into the WEBUSRDB database table. 9. Create a servlet and the DB access bean to update the WEBUSRDB database table on the AS/400 system. 10.Create the resulting JavaServer Pages (JSPs) to provide feedback to the user on the updating WEBUSRDB table. Note on steps 8 through 10 Steps 8 through 10 are accomplished using WebSphere Studio Database Wizard. The HTML input form, a servlet, and resulting JSPs will be generated all at the same time based on the SQL file created in step Write a simple Java code to calculate the next customer number, based on the result of the query in step 5. Insert the code into the CSTMR insertion servlet. 12.Modify the CSTMR table update servlet to insert Java code and INSERT logic for the WEBUSRDB table. 13.Clean up the CSTMR table based HTML input form and include user input for the WEBUSRDB table. 14.Modify the resulting page to confirm Web user creation Creating INSERT SQL for the CSTMR table In this section, we create the INSERT statement to insert a record into the CSTMR database table using WebSphere Studio SQL Wizard. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. UsetheSQLWizardtocreateanINSERTSQLfortheCSTMRtable. a. Select the project folder NewUser. b. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 168 Web Enabling AS/400 Applications with IBM WebSphere Studio

179 c. Proceed through the tabbed windows of the wizard, specifying the information described in Table 11. Table 11. Information to be entered in the SQL Wizard Tabbed window Welcome Action explanation Enter insertcstmr as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the databases, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or an IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is, APILIB in this case. Click on the library to select it, and click the Add button. Click the OK button to return to the Tables window. Select the Insert radio button in the Statement type. Select APILIB.CSTMR from the list of tables shown. Click Next. ABC Company Web site design and development 169

180 Tabbed window Insert Action explanation Select the columns that are to be part of the Insert statement. Refer to Figure 176 on page 183. For each column, enter a parameter value by clicking the Parameter button. Then, type in the name of the parameter. For the remaining columns, enter the parameter values directly into the text filed, without using the Parameter button. Refer to Figure 171 on page 171 and Figure 172 on page 171 to see the fields we selected and the values and parameters that we specified. Note: A plus sign + beside the column name designates a required column. It means you have to supply the value or the parameter. Until you supply the values or parameters for all required columns, the Next button will be disabled. If you do not want to update certain columns, supply a space for the value (for example: CDATA), and the Next button will become enabled. Click Next. SQL No action required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. Click Next. Finish Click the Finish button. The completed SQL file should appear in the project as insertcstmr.sql. 3. Check in the generated file insertcstmr.sql in the Studio Workbench. Figure 171 and Figure 172 show our selections and parameter specifications for insertcstmr.sql. 170 Web Enabling AS/400 Applications with IBM WebSphere Studio

181 Figure 171. Selecting fields and specifying parameters for insertcstmr.sql (Part 1) Figure 172. Selecting fields and specifying parameters for insertcstmr.sql (Part 2) ABC Company Web site design and development 171

182 Creating the HTML form, servlet, bean, and JSP for the CSTMR insert In this section, you create the input HTML form, the servlet, the bean, and resulting JSPs to insert a record into the CSTMR database table using WebSphere Studio Database Wizard. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Use the Database Wizard to create the servlet, HTML, and JSPs for inserting into the CSTMR table: a. Select the project folder NewUser. b. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. c. Select the appropriate SQL statement, that you created in the previous section. It should be drive:\subsites\newuser\insertcstmr.sql. d. Click Next. e. Proceed through the tabbed windows of the wizard, specifying the information described in Table 12. Table 12. Information to be entered in the Database Wizard Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files will be generated. You will need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens, and lastly: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. Click Next. Input Page Select all of the check boxes by clicking the Check All button. De-select the following fields: URL Driver UserID Password Move the fields, using the up arrow and down arrow buttons to interchange the order of the columns, as shown in Figure 173 on page 174. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for all parameters. Click Next. 172 Web Enabling AS/400 Applications with IBM WebSphere Studio

183 Tabbed window Results Page Action explanation Deselect all of the check boxes by clicking the Uncheck All button. Select the following options: first last cust and so on if you want to see some other fields The result page will be modified later in the process. Ensure that the Table radio button is selected. Click Next. Standard Error Page Methods Session Click Next. Click Next. Select the Yes, store it in the user s session radio button so that the generation bean will be placed in the session for the user. This will make the bean available for future use during the session. Name the bean custinsertdbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button, and type custinsert into the Prefix dialog. Click OK. Note that all of the files will now have the prefix of custinsert. Click the Finish button to generate the code. The Database Wizard will generate and compile the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 3. Check all of the generated files (all files having the custinsert prefix) into the Studio Workbench. Select the NewUser folder. Then, right-click, and select the Check In option. 4. Publish the project to the AS/400 server. Follow the same steps as in 4.3.1, Publishing to the AS/400 system on page To test record insertion into the CSTMR table, select the custinsertinput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the screen appears as shown in Figure 173 on page 174. ABC Company Web site design and development 173

184 Figure 173. Testing Insertion Function into CSTMR: Input 6. Enter values for all the fields, and click the Submit button to invoke the servlet. This will instantiate the bean, which will execute the query. The resulting JSP will be generated and sent to the client s browser. The result is displayed as shown in Figure 174. Figure 174. JSP result page of record insertion into CSTMR table Note The resulting JSPs have to be modified later to indicate a WEBUSRDB table updates Creating a SELECT SQL for CSMTR table In this section, you create a SELECT statement using the WebSphere Studio SQL Wizard. Then, you modify it to select the highest customer ID, so you can 174 Web Enabling AS/400 Applications with IBM WebSphere Studio

185 calculate the next customer ID to insert it into the CSTMR table and assign it to a new Web user. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. UsetheSQLWizardtocreateaSELECTSQLfortheCSTMRtable: a. Select the project folder NewUser. b. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. c. Proceed through the tabbed windows of the wizard by specifying the information described in Table 13. Table 13. Information to be entered in the SQL Wizard Tabbed window Action explanation Welcome Enter selectcstmr as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard need to connect to the database, for example: Database URL: jdbc:as400://system name Userid:user ID Password: password Driver:AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work. Which is APILIB in this case. Click the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select the APILIB.CSTMR from the list of tables. Click Next. Join No action is required. Click Next. ABC Company Web site design and development 175

186 Tabbed window Columns Action explanation Select only the CSTMR.CID column to be included in the output result. Click the Add button. Click Next. Condition 1 No action is required. Ideally, you want to select max(cid) to get the highest customer ID in result. However, the wizard does not allow statements of this kind. Thus, you are going to produce plain SELECT and modify the SQL statement later in the DB access bean (see Modifying the custselectdbbean bean on page 185). Click Next. Sort No action is required. Click Next. SQL No action is required. This tab shows the completed SQL statement. You can copy the statement to the clipboard to use in another application. Also you can test the SQL statement by clicking the Run SQL button. Click Next. Finish Click the Finish button. The completed SQL file should appear in the project as selectcstmr.sql. 3. Check the generated file selectcstmr.sql into the Studio Workbench Creating the servlet and DB access bean for CSTMR select In this section, you create the servlet and the DB access bean to get the result of CSTMR select query, which should produce the highest customer ID found in CSTMR. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Use the Database Wizard to create the servlet and the DB access bean: a. Select the project folder NewUser. b. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. c. Select the appropriate SQL statement, which you created in the previous section. It should be drive:\subsites\newuser\selectcstmr.sql. d. Click Next. 176 Web Enabling AS/400 Applications with IBM WebSphere Studio

187 e. Proceed through the tabbed windows of the wizard by specifying the information described in Table 14. Table 14. Information to be entered in the Database Wizard Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You do not need any input or result pages, since you will not show the results to the user, but rather use the result of the query to calculate the next customer ID. Uncheck all the Pages check boxes. Click Next. Methods Session Click Next. Select the Yes, store it in the user s session radio button so that the generation bean will be placed in the session for the user. This will make the bean available for future use during the session. Name the bean custselectdbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button and type into the dialog, custselect. Click the OK button. Note that all of the files now have the prefix of custselect. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 3. Check all of the generated files (all files having the custselect prefix) into the Studio Workbench. Select the NewUser folder. Right-click, and select the Check In option. 4. Modify the wizard s generated SQL statement to return only one row with the highest customer ID. You do this step later using IBM VisualAge for Java, as described in , Calculating and inserting new customer ID into the CSTMRtable onpage Publish the project to the AS/400 server. Follow the same steps described in 4.3.1, Publishing to the AS/400 system on page 125. ABC Company Web site design and development 177

188 Creating an INSERT SQL for WEBUSRDB table In this section, you create the INSERT statement to insert a record into the WEBUSRDB database table using WebSphere Studio SQL Wizard. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. UsetheSQLWizardtocreateanINSERTSQLfortheWEBUSRDBtable: a. Select the project folder NewUser. b. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. c. Proceed through the tabbed windows of the wizard by specifying the information described in the Table 15. Table 15. Information to be entered in the SQL Wizard Tabbed window Action explanation Welcome Enter insertwebusr as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid:user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user id and password; both should be in uppercase. Click Connect. The wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Select the library, and click the Add button. Click the OK button to return to the Tables window. Click the Insert radio button in the Statement type. Select APILIB.WEBUSRDB from the list of tables shown. Click Next. 178 Web Enabling AS/400 Applications with IBM WebSphere Studio

189 Tabbed window Insert Action explanation Select the columns that are to be part of the Insert statement. Refer to Figure 175 on page 180. For each column, enter a parameter value by clicking the Parameter button and then typing in the name of the parameter. For the remaining columns, enter the parameter values directly into the text filed, without using the Parameter button. Refer to Figure 175 on page 180 to see the fields we selected, values and parameters specified. Note: A plus sign (+) beside the column name designates the required column. It means you have to supply the value or the parameter. Until you supply the values or parameters for all required columns, the Next button will be disabled. If you do not want to update certain columns, supply a space for the value and the Next button will become enabled. Note: Using the following workaround, we recreated the WEBUSRDB table, allowing null values for DATE and TIME fields (see the following SQL statement). Then, we ran the wizard without specifying any values for the INSERT. After the wizard generated the.sql file, we recreated the file to have defaults for the fields: CREATE TABLE APILIB/WEBUSRDB (LOGIN_NAME CHAR ( 10) NOT NULL WITH DEFAULT PRIMARY KEY, PWD CHAR ( 10) NOT NULL WITH DEFAULT, WCID CHAR ( 4) NOT NULL WITH DEFAULT UNIQUE, CHAR ( 25) NOT NULL WITH DEFAULT, VLDTED NUMERIC ( 1) NOT NULL WITH DEFAULT 0, LOGGEDIN NUMERIC ( 1) NOT NULL WITH DEFAULT 0, DATE DATE, TIME TIME ) Click Next. SQL No action is required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. Click Next. Finish Click Finish. The completed SQL file should appear in the project as insertwebusr.sql. 3. Check the generated file insertwebusr.sql into the Studio Workbench. Figure 175 on page 180 shows selections and parameter specifications we used for insertwebusr.sql. ABC Company Web site design and development 179

190 Figure 175. Specifying parameters and values for columns in insertwebusr.sql Creating an HTML form, servlet, bean, and JSP In this section, you create the input HTML form, the servlet, the bean and the resulting JSPs to insert a record into the WEBUSRDB database table using WebSphere Studio Database Wizard. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Use the Database Wizard to create the servlet, HTML, and JSPs for inserting into the WEBUSRDB table: a. Select the NewUser project folder. b. Start the Database Wizard by selecting Tools->Wizards->Database Wizard. c. Select the appropriate SQL statement, which you created in the previous section. It should be drive:\subsites\newuser\insertwebusr.sql. d. Click Next. e. Proceed through the tabbed windows of the wizard, specifying the information described in Table Web Enabling AS/400 Applications with IBM WebSphere Studio

191 Table 16. Information to be entered in the Database Wizard Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the output page check box. c. Select the error page check box. Click Next. Input Page Select all of the check boxes by pressing the Check All button. Deselect the following fields: URL Driver UserID Password Note: The idea is to select all the fields, which you specified the parameter for inside the SQL. That way, you pass the parameter value into the SQL statement via the input form. Move the fields, using the up arrow and down arrow buttons, to interchange the order of the columns, as shown in Figure 176 on page 183. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for all the parameters. Click Next. Results Page Deselect all of the check boxes by clicking the Uncheck All button. Select login ID and so on if you want to see some other fields. The Result page will be modified later in the process. Ensure that the Table radio button is selected. Click Next. Standard Error Page Methods Click Next. Click Next. ABC Company Web site design and development 181

192 Tabbed window Session Action explanation Select the Yes, store it in the user s session radio button so that the generated bean will be placed in the session for the user. This will make the bean available for future use during the session. Name the bean webusrinsertdbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button, and type webusrinsert into the dialog. Click OK. Note that all of the files now have the prefix of webusrinsert. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 3. Check all of the generated files (all files having the webusrinsert prefix) into the Studio Workbench. Select the NewUser folder. Right-click, and select the Check In option. 4. Publish the project to the AS/400 server. Follow the same steps as outlined 4.3.1, Publishing to the AS/400 system on page To test record insertion into WEBUSRDB table, select the webusrinsertinput.html file to preview it. Then, right-click and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the window shown in Figure 176 appears. 182 Web Enabling AS/400 Applications with IBM WebSphere Studio

193 Figure 176. Testing the Insertion function into WEBUSRDB: Input 6. Enter values for all the fields, and click the Submit button to invoke the servlet, which will instantiate the bean. This executes the query, and the resulting JSP is generated and sent to the client s browser. The result is displayed as shown in Figure 177. Figure 177. JSP result page of record insertion into the WEBUSRDB table Note JSPs produced at this stage are primarily for unit testing of the servlets, beans, HTMLs created by the wizards. Input HTMLs and resulting JSPs have to be modified by Page Designer to achieve desired functionality and flow How servlets and beans generated by the DB Wizard work Up to this point, we did everything we could do using WebSphere Studio Wizards. The WebSphere Studio project should contain several files as illustrated in Figure 178 on page 184. ABC Company Web site design and development 183

194 Figure 178. NewUser project files generated by the wizards Let us briefly explain how it all works. After the files are published on the AS/400 WebSphere Application Server, they are ready to respond to the visitors' Web site activity. The following sequence shows the way these files are typically processed: 1. A Web site visitor goes to (requests) the input page. 2. The visitor submits the form, which calls the servlet with or without parameters. 3. The servlet calls (instantiates) the JavaBean, which implements the SQL statement. 4. The same servlet from step 3 then calls the appropriate JSP file (based on the servlet configuration file) to dynamically create the output page based on the bean s properties. 5. The server returns the output page to the browser. 6. You can enhance the HTML and JSP files in Page Designer and modify your Java code using IBM VisualAge for Java or any other Java IDE. You can launch any of the tools directly from the Studio Workbench. When you have completed your enhancements and are ready, check the files in, publish, and preview them. The following sections explain how to enhance a servlet or a bean generated by the Studio Wizards. They also explain how to modify HTML files to achieve desired the functionality and look. 184 Web Enabling AS/400 Applications with IBM WebSphere Studio

195 Calculating and inserting new customer ID into the CSTMR table In this section, you perform these tasks: 1. Modify the custselectdbbean.java bean to implement the SQL statement to return the highest customer ID from the CSTMR table. Recall that the SQL, servlet, and bean we created in , Creating the servlet and DB access bean for CSTMR select on page 176, implements an SQL statement, which simply returns all customer IDs from the CSTMR table. 2. Modify the custinsert.java servlet to update the CSTMR table with a calculated customer ID, and not with a customer ID entered on the input HTML screen (custinsertinput.html). 3. Unit test insertion logic into the CSTMR table. Modifying the custselectdbbean bean The beans created by Database Wizard have the following components: Properties: Implemented as instance variables Setters and getters: Methods to set and get the values of the bean properties Other methods, such as initialize(), execute(), andutility methods A servlet calls an execute() method of the bean, which executes the initialize() method and then executes an SQL statement. The JavaServer Page (JSP) contains Java code to retrieve the bean s properties including the SQL result via using the getters. Modifying Java files with VisualAge for Java After you create servlets (and their JavaBeans) with the wizards, you can modify these classes in VisualAge for Java. WebSphere Studio integrates with VisualAge for Java 3.0. If you have VisualAge for Java 3.0 installed, you can navigate between the two products. Send Java files there for editing and maintenance, and then refresh your copy in WebSphere Studio before publishing. See 3.6, VisualAge for Java 3.0 Professional Edition on page 120. The SQL statement in custselectdbbean is a property called SQLString: /** * Instance variable for SQL statement property */ protected java.lang.string SQLString = "SELECT APILIB.CSTMR.CID FROM APILIB.CSTMR"; Double-click custselectdbbean.java to edit the file. Change the SQL statement to select the maximum value of the CID column. The modified code should be as follows: /** * Instance variable for SQL statement property */ protected java.lang.string SQLString = "SELECT max(apilib.cstmr.cid) FROM APILIB.CSTMR"; Save, check in, and compile the file to reflect the changes in the.class file. This method should be used if and only if the SQL wizard is not capable of producing the desired SQL statement. ABC Company Web site design and development 185

196 Modifying the custinsert servlet In this section, you perform the following tasks: 1. Modify the custinsert servlet to instantiate (call) custselectdbbean to get the highest customer ID found in the CSTMR table. 2. Insert the code into custinsert.java to calculate the next customer ID. 3. Propagate a new customer ID into custinsertdbbean, which implements an INSERT SQL statement for the CSTMR table. We propagate a new customer ID value via using the setter method of custinsertdbbean. Double-click custinsert.java to edit the file. Find the following section in the code: // Imports for beans used by this servlet import NewUser.custinsertDBBean; Since you have to instantiate (call) custselectdbbean, you need to have access to some of its properties and methods. The new version of the import section in the code should look like the following example: // Imports for beans used by this servlet import NewUser.custinsertDBBean; import NewUser.custselectDBBean; Next, copy the instantiation block of code from the performtask() method in the custselect.java servlet into the performtask() method in the custinsert.java servlet. Double-click custselect.java to edit the file. Find the following section in the code as shown in Figure 179. Highlight and copy it to the clipboard. 186 Web Enabling AS/400 Applications with IBM WebSphere Studio

197 // instantiate the beans and store them so they can be accessed by the called page NewUser.custselectDBBean custselectdbbean = null; custselectdbbean = (NewUser.custselectDBBean) java.beans.beans.instantiate(getclass().getclassloader(), "NewUser.custselectDBBean"); session.putvalue("custselectdbbean", custselectdbbean); // Initialize the bean userid property from the parameters custselectdbbean.setuserid(getparameter(request, "userid", true, true, false, null)); // Initialize the bean password property from the parameters custselectdbbean.setpassword(getparameter(request, "password", true, true, false, null)); // Initialize the bean URL property from the parameters custselectdbbean.seturl(getparameter(request, "URL", true, true, false, null)); // Initialize the bean driver property from the parameters custselectdbbean.setdriver(getparameter(request, "driver", true, true, false, null)); // Call the execute action on the bean. custselectdbbean.execute(); Figure 179. Code block to be inserted into the custinsert servlet Paste the copied block inside the performtask() method in custinsert.java right after the following lines: try { HttpSession session = request.getsession(true); Type in meaningful online documentation for the inserted block. The following block of code executes the SQL statement and set or loads the bean properties with the result data: // Call the execute action on the bean. custselectdbbean.execute(); This means you can use the getter method to get the result of SQL statement execution, which is the highest customer ID currently in the CSTMR table. Next, insert the following line of code inside the performtask() method in custinsert.java right after the first { (bracket) before the first try block. We feed the customerid variable populated with a calculated customer ID into the INSERT SQL statement implemented by custinsertdbbean and later by webusrinsertdbbean: StringBuffer customerid = new StringBuffer(4); To get the highest customer ID found and calculate the next customer ID to be inserted into the CSTMR table, insert the code as shown in Figure 180 on page 188 after the following lines: // Call the execute action on the bean. custselectdbbean.execute(); ABC Company Web site design and development 187

198 // Calculate new customer number by getting the custselectdbbean cust property String cust = custselectdbbean.getapilib_cstmr_cid(0); java.math.biginteger custn = new java.math.biginteger(cust); custn = custn.add(new java.math.biginteger("1")); String newcust = custn.tostring(); for(int i=0; i < 4 - newcust.length(); i++) { customerid.append('0'); } customerid.append(newcust); Figure 180. Calculating the next customer ID code to be inserted into the custinsert servlet It has to be within the try block to be in scope with bean instantiation logic. That way, the bean properties are visible and accessible. We convert the character type customer ID found into a numeric type, increment it by one, convert it back to character, and supply leading zeroes. Now locate the following line of code: // Initialize the bean cust property from the parameters custinsertdbbean.setcust(getparameter(request, "cust", true, true, true, null)); This is how the servlet gets the value of cust from the input HTML page and passes it to the bean, which in turn uses the value of cust for an SQL INSERT statement. Modify the code to use the calculated value. Comment out the line generated by the wizard and type in the following statement below the commented line: custinsertdbbean.setcust(customerid.tostring()); Unit testing customer insertion Perform the following tasks to unit test the customer insertion: 1. Compile the files you modified. 2. Publish the project to the AS/400 server. Follow the same steps explained in 4.3.1, Publishing to the AS/400 system on page Select the custinsertinput.html file. Then, right-click, and select Preview file with Netscape or Internet Explorer. 4. When the Web browser appears, complete the form, and click the Submit button as illustrated in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

199 Figure 181. Unit testing by calculating and inserting a new customer ID into CSTMR: Input 5. The result page should reflect the changes. Notice the cust ID in Figure 182 is equal to 3407, even though, we have not entered the value for the customer on the input page (it would not matter even if we entered the value). The result is 3407 because our highest customer ID in the CSTMR table used to be Figure 182. Unit testing by calculating and inserting a new customer ID into CSTMR: Result Inserting a new customer ID into the WEBUSRDB table In this section, you perform these tasks: 1. Modify the custinsert.java servlet to include the WEBUSRDB table INSERT logic. Supply the value of the calculated customer ID for INSERT SQL for the WEBUSRDB table. 2. Unit test insertion logic into WEBUSRDB table. Modifying the custinsert servlet In this section you propagate a new customer ID into webusrinsertdbbean, which implements an INSERT SQL statement for the WEBUSRDB table. You propagate a new customer ID value using the setter method of webusrinsertdbbean. ABC Company Web site design and development 189

200 Double-click custinsert.java to edit the file. Find the following section in the code: // Imports for beans used by this servlet import NewUser.custinsertDBBean; import NewUser.custselectDBBean; Since you have to instantiate (call) webusrinsertdbbean, you need access to some of its properties and methods. The new version of the import section in the code should look like the following example: // Imports for beans used by this servlet import NewUser.custinsertDBBean; import NewUser.custselectDBBean; import NewUser.webusrinsertDBBean; Next, you copy the instantiation block of code from the performtask() method in the webusrinsert.java servlet into the performtask() method in the custinsert.java servlet. Double-click webusrinsert.java to edit the file. Find the following section in the code, shown in Figure 183, and highlight and copy it to the clipboard. 190 Web Enabling AS/400 Applications with IBM WebSphere Studio

201 // instantiate the beans and store them so they can be accessed by the called page NewUser.webusrinsertDBBean webusrinsertdbbean = null; webusrinsertdbbean = (NewUser.webusrinsertDBBean) java.beans.beans.instantiate(getclass().getclassloader(), "NewUser.webusrinsertDBBean"); session.putvalue("webusrinsertdbbean", webusrinsertdbbean); // Initialize the bean userid property from the parameters webusrinsertdbbean.setuserid(getparameter(request, "userid", true, true, false, null)); // Initialize the bean password property from the parameters webusrinsertdbbean.setpassword(getparameter(request, "password", true, true, false, null)); // Initialize the bean URL property from the parameters webusrinsertdbbean.seturl(getparameter(request, "URL", true, true, false, null)); // Initialize the bean driver property from the parameters webusrinsertdbbean.setdriver(getparameter(request, "driver", true, true, false, null)); // Initialize the bean cust property from the parameters // webusrinsertdbbean.setcust(getparameter(request, "cust", true, true, true, null)); webusrinsertdbbean.setcust(customerid.tostring()); // Initialize the bean pwd property from the parameters webusrinsertdbbean.setpwd(getparameter(request, "pwd", true, true, true, null)); // Initialize the bean loginid property from the parameters webusrinsertdbbean.setloginid(getparameter(request, "loginid", true, true, true, null)); // Initialize the bean property from the parameters webusrinsertdbbean.set (getparameter(request, " ", true, true, true, null)); // Call the execute action on the bean. webusrinsertdbbean.execute(); Figure 183. The webuserinsert.java code segment to be copied into the custinsert servlet Paste the copied block inside the performtask() method in custinsert.java right after the following line: customerid.append(newcust); and before these lines: // instantiate the beans and store them so they can be accessed by the called page NewUser.custInsertDBBean custinsertdbbean = null; Type in meaningful online documentation for the inserted block. As soon as the next customer ID is calculated, insert the record into WEBUSRDB (the webusrinsertdbbean.execute() method is run and we instantiate (call) custinsertdbbean to insert the record into the CSTMR table. However, you need to feed the calculated customer ID, instead of the one entered on the input HTML form. ABC Company Web site design and development 191

202 Find the following line of code: // Initialize the bean cust property from the parameters webusrinsertdbbean.setcust(getparameter(request, "cust", true, true, true, null)); This is how the servlet gets the value of cust from the input HTML page and passes it to the bean, which in its turn uses the value of cust for the SQL INSERT statement. Modify the code to use the calculated value (see , Calculating and inserting new customer ID into the CSTMR table on page 185). Comment out the line generated by the wizard and type in the following line below the commented line: webusrinsertdbbean.setcust(customerid.tostring()); Unit testing Web user insertion Compile and check in the files you modified. Since Web-user insertion logic should occur at the same time with new customer record insertion, you cannot unit test just the Web user function. Instead, in the following section, you modify custinsertinput.html using Page Designer to include fields and parameters for Web-user insertion logic Combining CSTMR and WEBUSRDB input HTML forms In this section, you perform these tasks: 1. Modify the custinsertinput.html input form to include input elements from the webusrinsertinput.html form. 2. Test insertion logic in the CSTMR and WEBUSRDB tables. Modifying the custinsertinput.html input form We merge webusrinsertinput.html into custinsertinput.html and not the other way around. When the Submit button is clicked, the custinsert servlet is called, which is where you calculate new customer ID and insert the input information into the CSTMR and WEBUSRDB tables. Also, the WEBUSRDB table contains fewer data elements to be inserted in comparison to the CSTMR table. Open custinsertinput.html and webusrinsertinput.html for editing in Page Designer. Refer to Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

203 Figure 184. Combining HTML input forms to generate a new Web user Follow this easy method: 1. Delete unnecessary table rows from custinsertinput.html, for example, cust. 2. Add new empty rows into the table inside custinsertinput.html. 3. Type the description (left table column cells) in the newly created rows. 4. Copy the text entry area (right table-column cells) from the table inside webusrinsertinput.html into the appropriate right-most cell inside the table inside custinsertinput.html. During the copy and paste, all the properties and attributes of the field are preserved. Figure 185 on page 194 shows combined forms. ABC Company Web site design and development 193

204 Figure 185. Combined HTML input forms to generate a new Web user If you double-click on the text entry area, you can examine the field name which is used by the beans and the servlets (Figure 186). Figure 186. Attributes of the name pwd 194 Web Enabling AS/400 Applications with IBM WebSphere Studio

205 Unit testing the new Web user creation Perform the following tasks to unit test the Web user insertion: 1. Compile the files you modified. 2. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page Select the custinsertinput.html file. Then right-click, and select Preview file with Netscape or Internet Explorer. 4. When the Web browser appears, complete the form, and click Submit, as illustrated in Figure 187. Figure 187. New Web user creation test: Input The result page should reflect the changes as illustrated in Figure 188. Figure 188. New Web user creation test: Result Examine the CSTMR and WEBUSRDB tables on the AS/400 system to verify record insertion. ABC Company Web site design and development 195

206 Creating a final resulting JSP It is always a good idea to provide a confirmation (result) page after a critical action has been performed. In our case, we provide confirmation on the INSERTs database into the CSTMR and WEBUSRDB tables. In this section, you perform these tasks: 1. Modify the custinsertresult.jsp result page to also include elements from webusrinsertresult.jsp, the result page of the record insertion into WEBUSRDB. 2. Test the insertion logic into the CSTMR and WEBUSRDB tables and the confirmation JSP result page. Modifying the custinsertresult.jsp We merge webusrinsertresult.jsp into custinsertresult.jsp. JSPs, which we generated with the help of the Database Wizard. JSPs contain HTML bean tags. If the bean is instantiated, then the bean tags allow access to the bean s properties. WebSphere Studio Page Designer simplifies JSP enhancements and modifications by letting you drag and drop the entire bean or select the bean s properties to be placed on the JSPs. Let us examine the WebSphere Studio Page Designer abilities within our scenario. Open custinsertresult.jsp and webusrinsertresult.jsp for editing in Page Designer. Refer to Figure 189. Figure 189. Merging custinsertresult.jsp and webusrinsertresult.jsp 196 Web Enabling AS/400 Applications with IBM WebSphere Studio

207 The first J (in green color) in custinsertresult.jsp represents the bean tag. The J inside the table rows with! on each sides represents bean s properties to be displayed on the page. Exclamation marks on each side represent meta tags with descriptions. Refer to the Figure 190 and Figure 191 on page 198 to see the actual source for the bean tag and Page Designer dialog box representing the bean tag. Figure 190. Actual source of the bean tag inside the custinsertresult.jsp If you double-click on the first J inside the Page Designer, you get the bean tag represented via the dialog box shown in Figure 191 on page 198. ABC Company Web site design and development 197

208 Figure 191. Bean tag inside the custinsertresult.jsp represented in the dialog box The J inside the table rows (refer to Figure 189 on page 196) represents the following actual source line. In the example, the custinsertdbbean.getcust() getter method is called, which results in the customer ID being displayed on the page: <!--METADATA type="dynamicdata" startspan <WSPX:PROPERTY property="custinsertdbbean.cust">--><%=custinsertdbbean.getcust() %><!--METADATA type="dynamicdata" endspan--> Note Refer to 3.3, Page Designer on page 88, for an in-depth demonstration of Page Designer capabilities. Since custinsertresult.jsp should include webusrinsertdbbean properties, you have to insert the webusrinsertdbbean tag first. There are three ways to do it: Select Insert->JSP Tags->Insert a Bean from the pull-down menu. Drag and drop a bean from Studio Workbench onto Page Designer where you are editing custinsertresult.jsp. Copy the Js from webusrinsertresult.jsp and paste it into custinsertresult.jsp. The reason you open both JSPs for editing is to use the copy and paste method. After copying and pasting, save custinsertresult.jsp and close the Page Designer. Open the Page Designer with custinsertresult.jsp. Figure 192 shows the result of the copy and paste action. 198 Web Enabling AS/400 Applications with IBM WebSphere Studio

209 Figure 192. Copying and pasting webusrinsertresult.jsp elements into custinsertresult.jsp The first J is the bean tag for custinsertdbbean, which is needed to display the bean s properties. The next J is the bean tag for webusrinsertdbbean. At this point, you have not yet used the Page Designer feature to select a bean s property to be placed, and displayed, on the page. Let us reformat the screen to demonstrate the feature. Position your cursor after the phrase The login Id:. Select Insert->Dynamic Elements->Property Display... (Figure 193 on page 200). ABC Company Web site design and development 199

210 Figure 193. Selecting bean properties to be displayed on the JSP Click Browse to see the available properties. Expand webusrinsertdbbean to select the loginid property to be placed on the page (Figure 194). Figure 194. Selecting the loginid property of the webusrinsertdbbean The loginid property is placed on the page in the location where cursor is. The property is represented by J (green box). If you double-click on the J you just inserted, a display like the example in Figure 195 appears. 200 Web Enabling AS/400 Applications with IBM WebSphere Studio

211 Figure 195. Examining the loginid property inserted into JSP with Page Designer Now give the page a more user-friendly look. Start by removing the tables created by the wizards, and then inserting first and last names, which are the properties of custinsertdbbean (Figure 196). Figure 196. custinsertresult.jsp final look Double-click J to investigate which property of which bean it represents. Save custinsertresult.jsp. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page 125. ABC Company Web site design and development 201

212 Testing the resulting JSP Perform the following tasks to test the resulting JSP: 1. Select the custinsertinput.html file. Then, right-click, and select Preview file with Netscape or Internet Explorer. 2. When the Web browser appears, complete the form (make sure to supply a different login ID to avoid duplicate keys in the WEBUSRDB table). Click the Submit button (Figure 197). Note: We deal with the potential duplicate keys error in the next section. Figure 197. custinsertresult.jsp test: Input form The result page should reflect the changes illustrated in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

213 Figure 198. custinsertresult.jsp test: Resulting page 3. Examine the CSTMR and WEBUSRDB tables on the AS/400 system to verify record insertion Input data validation Have you ever heard the phrase Garbage in, garbage out? Data validation plays an important role in preserving data accuracy and assuring the integrity of your databases. There are two types of data validation: client side (primitive) and server side (business rules). Client side validation is performed within the browser without making any request to the server. Since we use a thin client model, there is no business logic on the client. To ensure business rules are followed, input is sent to the server for analysis and feedback is provided via the JSP to the client. Examples of primitive validation ensure a specific data type, such as numeric entry, enforcing mandatory entry, enforcing lower or upper casing, and so forth. Business rules validation means ensuring data entry does not break any business rules built into the enterprise applications and databases. For the ABC Company, you perform the following steps: 1. On the client side, complete these tasks: a. Enforce mandatory entries. b. Enforce uppercase on the input form. c. In some cases, specify field lengths according to the server side database. 2. On the server side, ensure that you do not end up with WEBUSRDB records without associated CSTMR records and vice versa (preserving referential integrity). Note The validation we perform may not be complete. Our goal is to illustrate the concept and different methods that you can use to perform proper and complete validation. ABC Company Web site design and development 203

214 We decided to use JavaScript to perform validation within the browser on the client s side. Refer to the following Web sites for more information on JavaScript. JavaScript Guide: JavaScript Reference: Validating new user input In this section, you modify the custinsertinput.html form to perform the following tasks: 1. Change users input to uppercase. 2. Enforce mandatory entries on required fields. 3. For some fields, specify field length according to the server side database. You will use JavaScript functions, form objects, and operators to do most of the work. Field lengths are changed using the Page Designer Attribute dialog box. Changing user input to uppercase Perform the following tasks to change the user input to uppercase: 1. Open custinsertinput.html for editing within Page Designer. 2. Double-click on the text entry area of the first Name field. You should see a display like the example in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

215 Figure 199. Changing user-supplied text to uppercase 3. Click the Extended button to access the Extended Attributes dialog box. 4. Click the Event tab to specify an event and associated action. 5. In the Event list, find and highlight the OnChange event as illustrated in Figure 200 on page Click the Add button to add the OnChange event to the Event-Action list. ABC Company Web site design and development 205

216 Figure 200. Selecting the OnChange event to uppercase entered text 7. Highlight the OnChange event within the Event-Action pane (center), and type the following text in the Script entry field, as illustrated in Figure 201: this.value=this.value.touppercase(); 8. Click Configure. 9. Continue clicking OK until you are back to Page Designer. Let us analyze the code. We use JavaScript to retrieve the input field s value. Sinceweareworkingatthefieldlevel,this means this particular input field object. If you specify this at the form level, it would mean this form object. Then, apply the JavaScript function touppercase(); to change the fields value. Figure 201. Supplying an action for the OnChange event Once you reach Page Designer, investigate the actual HTML source: 206 Web Enabling AS/400 Applications with IBM WebSphere Studio

217 1. Click on HTML Source tab. 2. Refer to Figure 202 to see the code in uppercase in the first input field using the OnChange event. Figure 202. HTML source showing uppercasing the first name field with the onchange event Up to this point, we showed you how to put the input values in uppercase through the dialog boxes. To apply the uppercase function to the rest of the fields, the copy and paste method can be used while within the HTML source view in Page Designer: 1. Highlight the following code segment: onchange="this.value=this.value.touppercase();" 2. Copy and paste the code segment to the end of the INPUT HTML construct (between the <> symbols) for other input fields. We applied the uppercase function to the following fields: first init last city state loginid password Recall that uppercasing occurs within the browser on the client, so you do not have to click the Submit button to test your work. Enforcing mandatory entries in the required fields Some information elements are critical, without which database integrity cannot be achieved. The required fields in our example are: first last addr1 city state ABC Company Web site design and development 207

218 zip login Id password We create JavaScript function to evaluate field values. If the required field is not populated, the alert message box is displayed and the form is not submitted. The function is called when the user presses the Submit button. We specify the function call in the OnClick event for the Submit button, and we pass this.form object. The validation is performed within the browser on the client s machine and is not submitted to the server. Here are the steps to invoke the validate() function and the function code itself: 1. Open custinsertinput.html in Page Designer for editing. 2. Double-click the Submit button to change the attributes to insert the validate() function call and function code. 3. Click the Extended button to open the Extended Attributes dialog box. 4. Click the Event tab to specify an event and associated action. 5. In the Event list, find and highlight the OnClick event. 6. Click the Add button to add an OnClick event to the Even-Action list. 7. Highlight the OnClick event within the Event-Action pane (center), and type the following statement in the Script entry field (Figure 203). return validate(this.form); 8. Click Configure. 9. Click Script. The window shown in Figure 203 should open. Figure 203. Inserting validate() function into custinsertinput.html (Part 1) 10.Highlight the text shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

219 Figure 204. Inserting the validate() function into custinsertinput.html (Part 2) 11.Type or paste the validate() function on top of the highlighted text in step 10 (Figure 205). Figure 205. The validate() function inserted into custinsertinput.html 12.Click the OK button all the way back to Page Designer. Then save custinsertinput.html, and close Page Designer. ABC Company Web site design and development 209

220 The code and HTML tags shown in Figure 206 were created by Page Designer. Figure 206. JavaScript code and HTML tags created by Page Designer inside custinsertinput.html Let us go through the function code shown in the Figure 205 on page 209 and Figure 206. The following line inside custinsertinput.html contains the validate() function call: <INPUT type="submit" name="submit" id="submit" value="submit" onclick="return validate(this.form);"> When the user clicks the Submit button, the onclick event is monitored. As a result of the onclick event, the validate() function is called and the form object is passed. Notice we call the function using the return keyword. The return keyword gives us the ability to allow or disallow the form to be submitted (sent to the server). Here is how it works. When the validate() function runs and returns false, the form is not submitted (sent to the server). If we omit the return keyword, the form is submitted regardless of whether the function returns true or false. Let us comment on the validate() function itself. We accept the passed parameter as theform. This parameter is an object with properties. The set of properties also includes the fields on the form and their associated values. We are using a giant if...else... construct to go through the required field values, trying to find one with value less-than blanks, which would mean the field does not contain any text. Notice we declared return_var to contain true or false values. If all the required fields have a value, then the function returns true, which causes the form to be submitted. However, if at least one of the fields does not have a value, the 210 Web Enabling AS/400 Applications with IBM WebSphere Studio

221 function displays an alert window with the proper error message, returns false, and the form is not submitted. The form is submitted to the server if and only if the function returns true. The validate() function can be enhanced to perform many other checks, which could be done before the form is submitted. Normally, this kind of function is used to clean up the user input, stop bad data from being submitted to the server, and do simple calculations. You should not try to let a function like this evaluate the input for certain business rules. Keep as many business rules and logic as possible on the server. Specifying a specific field length During the page creation using WebSphere Studio Database Wizard, input capable field sizes are given the default number of characters, which may not suit your particular environment. To limit the input to a certain number of characters to comply with backend database attributes, text entry capable fields may be changed. In our example, fields, such as middle initial and state fields, have been changed to a particular size, CSTMR table attributes. Field sizes can be changed during page creation using the wizard or using the Page Designer. The Input Page tab in the Database Wizard allows modification of the field s size. See Figure 207 for an example of the dialog box, which appears when the input field is highlighted and the Change button is clicked. Figure 207. Changing the size of the state field inside the DB wizard Inside the Page Designer, you can change a field size via the Attributes dialog box as illustrated in Figure 208 on page 212. You can even change columns and maximum length values. ABC Company Web site design and development 211

222 Figure 208. Changing field size inside the Page Designer Cleaning up and testing validation functionality of custinsertinput.html In this section, you clean up custinsertinput.html and perform data validation testing. Perform the following tasks: 1. Open custinsertinput.html for editing inside the Page Designer. 2. Enter meaningful field captions in the left-most table column. 3. Change the field captions color to red if the field has a mandatory entry. 4. Change the heading of the form as well. The final page is illustrated in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

223 Figure 209. Cleaning up the custinsertinput.html 5. Save custinsertinput.html. 6. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page 125. Unit testing data validation functionality Perform the following tasks to test data validation functionality: 1. Select the custinsertinput.html. Then, right-click and select Preview file with Netscape or Internet Explorer. 2. When the Web browser appears, enter information in all the fields except the Login ID and fields. 3. Verify that the uppercase function is working. You should get the alert message box shown in Figure 210 on page 214. ABC Company Web site design and development 213

224 Figure 210. Alert message box to indicate a mandatory field entry Data validation summary The validation techniques we have demonstrated in this section apply mostly to the client s side data validation. JavaScript language can be used to evaluate the type of input (character or numeric), field s value, change the casing, and so forth. When using JavaScript, make sure to test the function on as many browsers as possible. Not all the Web browsers fully support JavaScript functions. If the input form passes the primitive validation, it is submitted to the server. The servlet custinsert.class starts. Recall, first it issues a query to find last and calculates the next customer number to assign to a new user. Then, we insert the record into WEBUSRDB table using the new customer ID we calculated. And, finally, we insert the record into CSTMR table. Login ID entered by a new user is the key field of the WEBUSRDB. Ideally, we should have made sure that this login ID was not used by another user prior to issuing the INSERT SQL statement. In this example, if login was found, JSP would have been sent to the user asking them to specify a new login ID. That would constitute server-side validation. Since we demonstrated the power of SQL Wizard and Database Wizard, which generate SQL statements, servlets, and beans, we do not check for duplicate login IDs first in this case. Instead, we rely on the SQL exception that is generated when it tries to insert the record with duplicate key. Database, SQL, database manager, connection manager, and other kinds of exceptions stop the process within a try {} block and fall into the catch {} block. Recall that we try to insert the record into the WEBUSRDB table prior to inserting the record into the CSTMR table. Therefore, having a customer ID inside the WEBUSRDB table, points to a customer record, which does not exist yet. It is considered bad practice, and we are not arguing that the way ABC Web site works is the best possible. However, we accomplish the point that: if a duplicate login ID is found 214 Web Enabling AS/400 Applications with IBM WebSphere Studio

225 (SQL exception generated), the customer record is not inserted as well. It becomes a pseudo transaction, in which a principle all or nothing is preserved. Even though a newly created WEBUSRDB table record points to a nonexistent CSTMR table record, it lasts only a split second. The probability that the CSTMR record will not get inserted is low and negligible. That is how we ensure database referential integrity. Needless to say, we did not perform new user functionality tests with thousands of clients at the same time. Clearly it is outside of the scope of the book, which focuses on WebSphere tools, concepts, and Web-site creation methodology New user creation summary and final testing This section concludes new user subsite development. You had a chance to experience the power of SQL Wizard and Database Wizards, and how easy it is to modify wizard-generated code and pages. You also worked with Page Designer tool to modify the look and feel of the pages, insert JavaScript functions, drag and drop the beans, and so forth. We found WebSphere Studio as an adequate set of tools to do the Web site development, generate simple HTML pages, servlets, database access beans, and JSPs. In 8.5, Tying it all together on page 389, and 8.7, Task summary and integration testing on page 402, we demonstrate how to tie different subsites into a complete Web site and perform integration testing. 7.3 Creating the catalog subsite The catalog subsite allows you to display the catalog to your customer. There are several ways in which you can deliver information. But, for this book, we have limited it to view all catalog items and view items by price range Creating the catalog project To build the catalog subsite, you need to create a new project. Follow the steps below to create the new catalog project folder: 1. Start WebSphere Studio if not already started. 2. Create a new project by selecting File->New Project from the pull-down menu. 3. Type Catalog for the project name. 4. Type drive:\subsites\catalog for the project folder. 5. Select <none> for project template. A new project is created called Catalog Creating the SQL queries for the catalog subsite Before beginning this section, you should already be familiar with the SQL Wizard discussed in 3.2, Studio Wizards on page Selecting all items from the catalog Perform the following tasks that run the SQL Wizard to create an SQL statement that selects all items from the catalog: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. ABC Company Web site design and development 215

226 3. Start the SQL Wizard by selecting Tools ->Wizards ->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information described in Table 17. Table 17. Creating a select all query for the catalog Tabbed window Action explanation Welcome Enter viewallcatalogitems as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select the APILIB.ITEM from the list of tables shown. Click Next. Join No action is required. Click Next. Columns You only want to provide to the user information concerning the product name and price. Select only the ITEM.IName and ITEM.IPrice columns to be included in the output result. Click the Add button. Click Next. 216 Web Enabling AS/400 Applications with IBM WebSphere Studio

227 Tabbed window Condition 1 Action explanation All items will be displayed so there is no condition to be entered. Click Next. Sort You want to display all the products in alphabetical order. Select the APILIB.ITEM.INAME. ClicktheAdd button to add it to our columns to sort on the list box. Make sure the sort order is set to Ascending. Click Next. SQL No action required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. Also you can test the SQL statement by clicking the Run SQL button. Click Next. Finish Click the Finish button. The completed SQL file should appear in the project as viewallcatalogitems.sql. 5. Check the generated file viewallcatalogitems.sql into the Studio Workbench. Select the Catalog folder. Then, right-click, and select the Check In option Selecting by price range from the catalog Perform the following tasks that run the SQL Wizard to create an SQL statement that selects items from the catalog by price range: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 18. Table 18. Creating a select by price range query for the catalog Tabbed window Action explanation Welcome Enter viewbypricecatalogitems as the name of the query. The wizard will add an.sql file in your project. Click Next. ABC Company Web site design and development 217

228 Tabbed window Logon Action explanation Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid:user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window find the AS/400 library with which you wantto work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click the OK button to return to the Tables window. Click the Select radio button in the Statement type. Select the APILIB.ITEM from the list of tables shown. Click Next. Join No action required. Click Next. Columns You only want to provide to the user information concerning the product name and price. Select only the ITEM.IName and ITEM.IPrice columns to be included in the output result. Click the Add button. Click Next. 218 Web Enabling AS/400 Applications with IBM WebSphere Studio

229 Tabbed window Condition 1 Action explanation Select IPrice in the Columns list box. Select the operator to be is greater than or equal to (>=). Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name minprice, and click OK. Now that we have the minimum price condition is set, you need to add the maximum price. Click the Find on another column button. Click Next. Condition 2 Make sure the radio button Find fewer rows (AND) at the top is selected. Select IPrice in the Columns list box. Select the operator to be is less than or equal to (<=). Click in the top values field, and click on the Parameter button. In the Create a new parameter dialog box, enter the variable name maxprice, and click OK. You now have your condition to select a price range. Click Next. Sort You want to display all the products in order of cheapest to most expensive. Click APILIB.ITEM.IPRICE. Now,clicktheAdd >> button to add it to our columns to sort on list box. Make sure the sort order is set to Ascending. Click Next. SQL No action is required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. If you choose to test the SQL statement by pressing the Run SQL button, you are prompted for two parameters in the Specify Parameter Value(s) window. For the first parameter, type 2.00 and for the second parameter. The result should be all items in the catalog that have the price range between or equal to $2.00 and $ Click OK. Click the Next button to go to the next tab. Finish Click the Finish button. The completed SQL file should appear in the project as viewbypricecatalogitems.sql. ABC Company Web site design and development 219

230 5. Check the generated file viewbypricecatalogitems.sql into the Studio Workbench. Select the Catalog folder. Then, right-click, and select the Check In option Selecting a single item from the catalog Perform the following tasks that run the SQL Wizard to create a SQL statement that selects a single item from the catalog: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools ->Wizards ->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 19. Table 19. Creating a query to select a single item from the catalog Tabbed window Action explanation Welcome Enter viewcatalogitem as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password. Both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window find the AS/400 library with which you want to work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select the APILIB.ITEM from the list of tables shown. Click Next. Join No action is required. Click Next. 220 Web Enabling AS/400 Applications with IBM WebSphere Studio

231 Tabbed window Columns Action explanation Click the Select All button. Hold down the Control key, and click on IDATA to deselect it. Click the Add button. Click Next. Condition 1 Click IID in the columns list box. Click the operator is exactly equal to. Click in the top Values fields, and click the Parameter button. In the Parameter dialog box, type prodid, and click the OK button. Click Next. Sort No action is required. There is no sort criteria for the single item. Click Next. SQL No action is required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. If you choose to test the SQL statement by clicking the Run SQL button, type for the test condition type. You should see all the product information for that product ID. Click the OK button. Click Next. Finish Click Finish. The completed SQL file should appear in the project as viewcatalogitem.sql. 5. Check the generated file viewcatalogitem.sql into the Studio Workbench. Select the Catalog folder. Then, right-click, and select the Check In option Inserting the selected item into the shopping cart Perform the following tasks that run the SQL Wizard to create an SQL statement that inserts the selected items into the shopping cart: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools ->Wizards ->SQL Wizard. ABC Company Web site design and development 221

232 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 20. Table 20. Creating an insert catalog item into shopping cart query Tabbed window Welcome Action explanation Enter addtocart as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with whichyouwanttowork, whichis APILIB in this case. Click on the library to select it, and click the Add button. Click the OK button to return to the Tables window. Click the Insert radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. Insert Select the columns that are to be part of the Insert statement. For each column, enter a parameter value by clicking the Parameter button and then typing in the name of the parameter: For SCID, type custid For SDSC, type prodname For SIID, type prodid For SPRC, type prodprice For SQTY, type prodqty Click Next. 222 Web Enabling AS/400 Applications with IBM WebSphere Studio

233 Tabbed window Action explanation SQL No action is required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. Click Next. Finish Click Finish. The completed SQL file should appear in the project as addtocart.sql. Note The previous query only deals with the shopping cart table. However, we have included it in the catalog section since all the input parameters come from the catalog. 5. Check the generated file addtocart.sql into the Studio Workbench Creating the Web pages for the catalog subsite Before beginning this section, you should already be familiar with the Database Wizard that was discussed in 3.2, Studio Wizards on page Displaying all items from the catalog Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select all records from the ITEM database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL Statement, which you created in , Selecting all items from the catalog on page 215. It should be drive:\subsites\newuser\viewallcatalogitems.sql. 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information described in Table 21 on page 224. ABC Company Web site design and development 223

234 Table 21. Using the Database Wizard to display all catalog items Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You must also: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The input page does not require any parameters. Click Next. Results Page The results page will already have the output parameters you wanted from the SQL file. These should be APILIB_ITEM_IID, APILIB_ITEM_INAME, and APILIB_ITEM_IPRICE. Select the parameters by clicking on the row and click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For IID, type Product ID For INAME, type Product Name For IPRICE, type Product Price Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session This bean is only to be used one time. We do not need to bind it to the session, so make sure No is selected. Name the bean viewallcatalogitemsdbbean. Click Next. 224 Web Enabling AS/400 Applications with IBM WebSphere Studio

235 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type viewallcatalogitems into the Prefix dialog. Click OK. Note that all of the files now have the prefix of viewallcatalogitems. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following added to the Studio Workbench: viewallcatalogitemserror.jsp viewallcatalogitemsinput.html viewallcatalogitemsnodata.jsp viewallcatalogitemsresults.jsp 7. Select the Catalog folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you will see that the following files have been created: viewallcatalogitems.class viewallcatalogitems.java viewallcatalogitems.servlet viewallcatalogitemsdbbean.class viewallcatalogitemsdbbean.java Displaying items from the catalog by price range Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select items from the ITEM database table by price range: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools ->Wizards ->Database Wizard. 4. Select the appropriate SQL Statement, which you created in , Selecting by price range from the catalog on page 217. It should be drive:\subsites\newuser\viewbypricecatalogitems.sql. 5. Click Next. ABC Company Web site design and development 225

236 6. Proceed through the tabbed windows of the wizard, and specify the information described in Table 22. Table 22. Using the Database Wizard to display the catalog based on a price range Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The user need to be able to search by a price range, so make sure the minprice and maxprice check boxes are both selected. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For minprice, type Minimum Product Price For maxprice, type Maximum Product Price Ensure that the Table radio button is selected. Click Next. Results Page The results page will already have the output parameters you wanted from the SQL file. These should be APILIB_ITEM_IID, APILIB_ITEM_INAME, and APILIB_ITEM_IPRICE. Select the parameters by clicking on the row and clicking the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For IID, type Product ID For INAME, type Product Name For IPRICE, type Product Price Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure the method named execute() is selected. Click Next. 226 Web Enabling AS/400 Applications with IBM WebSphere Studio

237 Tabbed window Session Action explanation This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean viewbypricecatalogitemsdbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button and type viewbypricecatalogitems into the Prefix dialog. Click the OK button, and note that all of the files will now have the prefix of viewbypricecatalogitems. Click the Finish button to generate the code. The Database Wizard generates and compiles the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following files added to the Studio Workbench: viewbypricecatalogitemserror.jsp viewbypricecatalogitemsinput.html viewbypricecatalogitemsnodata.jsp viewbypricecatalogitemsresults.jsp 7. Select the Catalog folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files have been created: viewbypricecatalogitems.class viewbypricecatalogitems.java viewbypricecatalogitems.servlet viewbypricecatalogitemsdbbean.class viewbypricecatalogitemsdbbean.java Displaying a single item from the catalog Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select a single item from the ITEM database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL statement, which you created in , Selecting a single item from the catalog on page 220. It should be drive:\subsites\newuser\viewcatalogitem.sql. ABC Company Web site design and development 227

238 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information described in Table 23. Table 23. Using the Database Wizard to display a single item from the catalog Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files that will be generated. You will need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The prodid check box should already be checked. Select the parameter by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. For prodid, type Product ID. Ensure that the Table radio button is selected. Click Next. Results Page The results page will already have the output parameters that you wanted from the SQL file. These should be APILIB_ITEM_IID, APILIB_ITEM_INAME, and APILIB_ITEM_IPRICE. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For IID, type Product ID For INAME, type Product Name For IPRICE, type Product Price Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click the Next button without changing any values. Click Next. Make sure the method named execute() is checked. Click Next. Session This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean viewcatalogitemdbbean. Click Next. 228 Web Enabling AS/400 Applications with IBM WebSphere Studio

239 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button and type viewcatalogitem into the Prefix dialog. Click OK. Note that all of the files now have the prefix viewcatalogitem. Click the Finish button to generate the code. The Database Wizard generates and compiles the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following files added to the Studio Workbench: viewcatalogitemerror.jsp viewcatalogiteminput.html viewcatalogitemnodata.jsp viewcatalogitemresults.jsp 7. Select the Catalog folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files have been created: viewcatalogitem.class viewcatalogitem.java viewcatalogitem.servlet viewcatalogitemdbbean.class viewcatalogitemdbbean.java Displaying the items listed in the shopping cart Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select a single item from the ITEM database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Catalog. 3. Start the SQL Wizard by selecting Tools ->Wizards ->Database Wizard. 4. Select the appropriate SQL statement, which you created in , Inserting the selected item into the shopping cart on page 221. It should be drive:\subsites\newuser\addtocart.sql. 5. Click Next. ABC Company Web site design and development 229

240 6. Proceed through the tabbed windows of the wizard, and specify the information described in Table 24. Table 24. Using the Database Wizard to display the items listed in the shopping cart Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. Click Next. Input Page All the input parameters we require should already be selected. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For custid, type Customer ID For prodname, type Product Name For prodid, type Product ID For prodprice, type Product Price For prodqty, type Product Quantity Ensure that the Table radio button is selected. Click Next. Results Page On the results page we just want to know if the data was added. Click in the custid check box. Click Next. Standard Error Page Methods Click the Next button without changing any values. Make sure the method named execute() is selected. Click Next. Session This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean addtocartdbbean. Click Next. 230 Web Enabling AS/400 Applications with IBM WebSphere Studio

241 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type addtocart into the Prefix dialog. Click OK. Note that all of the files now have the prefix of addtocart. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following files added to the Studio Workbench: addtocarterror.jsp addtocartinput.html addtocartresults.jsp 7. Select the Catalog folder. Right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files have been created: addtocart.class addtocart.java addtocart.servlet addtocartdbbean.class addtocartdbbean.java Testing the catalog pages Now that the Catalog Web pages have been built, you should test them to see if the results are what you want. It is much easier to fix the pages at this point if there is a problem. Perform the following steps to test the Catalog subsite: 1. Make sure you have your publishing target setup. Refer to 4.3.1, Publishing to the AS/400 system on page 125, if you have not done this yet. 2. Right-click on the Catalog project folder in the Studio Workbench, and select Publish whole Project. This publishes the entire Catalog project to your defined server, which is an AS/400 server in our case. ABC Company Web site design and development 231

242 Reminder At this point, you are only testing subsites. There is still a long way to go before you have the completed Web site. You should not deploy the Web site to a public production server for people to see until you are finished. You can publish your pages to a public server, but do not tell people about the pages for general viewing until the entire Web site is done. 3. Once you have published your Web pages, make sure your WebSphere Application Server and Web server are both started. 4. To test retrieving all items from the catalog, select the viewallcatalogitemsinput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the screen appears as shown in Figure 211. Figure 211. viewallcatalogitemsinput.html displayed in Netscape 5. Click the Submit button. You should see a Web page as shown in Figure 212. Note If you get an error page or something that you did not expect, try restarting the WebSphere Application Server and republishing the site. 232 Web Enabling AS/400 Applications with IBM WebSphere Studio

243 Figure 212. viewallcatalogitemsresult.jsp displayed in Netscape 6. To test retrieving items from the catalog by price range, select the viewbypricecatalogitemsinput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears as shown in Figure 213. Figure 213. viewbypricecatalogitemsinput.html displayed in Netscape 7. Set the minimum price to 2.00 and set the maximum price to Click the Submit button. The result page should appear as shown in Figure 214 on page 234. ABC Company Web site design and development 233

244 Figure 214. viewbypricecatalogresults.jsp displayed in Netscape 8. To test retrieving a single item from the catalog, select the viewcatalogiteminput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 215. Figure 215. viewcatalogiteminput.html displayed in Netscape 9. Type a product ID of Click the Submit button. The result page should appear as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

245 Figure 216. viewcatalogitemresults.jsp displayed in Netscape 10.To test adding an item to the shopping cart, select the addtocartinput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 217. Figure 217. addtocartinput.html displayed in Netscape 11.Complete the following parameters with the information shown: Customer ID: Type 0011 Product Name: Type Shoe Product ID: Type Product Price: Type ProdQty: Type Click the Submit button. The result page should appear as shown in Figure 218 on page 236. ABC Company Web site design and development 235

246 Figure 218. addtocartresults.jsp displayed in Netscape Creating the general catalog area You need the catalog to be accessible from two places: inside the registered user area and outside the registered user area. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Create a new project by selecting File->New Project from the pull-down menu. a. Type GeneralCatalog for the project name. b. Type drive:\subsites\generalcatalog for the project folder. c. Select <none> for the project template. 3. In the Studio Workbench, select Insert->Folder from the pull-down menu. Click the Use Existing tab. For Folder Name, type drive:\subsites\catalog. Then, click OK. 4. Expand the Catalog directory, and select all the files in the root of the Catalog directory. Drag these files to the GeneralCatalog directory. 5. Expand the servlet directory inside the Catalog directory. Drag the Catalog s servlet directory to the GeneralCatalog s servlet directory. 6. Right-click on the Catalog directory, and select Delete. 7. Delete the following files from this GeneralCatalog subsite: addtocart.sql addtocarterror.jsp addtocartinput.html addtocartresults.jsp viewcatalogitem.sql viewcatalogitemerror.jsp viewcatalogiteminput.html viewcatalogitemresults.jsp viewcatalogitemnodata.jsp addtocart.class addtocart.java addtocart.servlet addtocartdbbean.class addtocartdbbean.java viewcatalogitem.class viewcatalogitem.java viewcatalogitem.servlet viewcatalogitemdbbean.class viewcatalogitemdbbean.java 236 Web Enabling AS/400 Applications with IBM WebSphere Studio

247 8. Expand the servlet directory and the Catalog directory inside the servlet directory. 9. Click on the first file viewallcatalogitems.class. Holding down the Shift key, click on the last file called viewbypricecatalogitemsdbbean.java. 10.Select Edit->Find and Replace Text... from the pull-down menu. You should see a dialog box like the example in Figure 219. Figure 219. WebSphere Studio Find and Replace dialog box. 11.In the Find and Replace dialog box, use the following parameters: a. For the Find what field, type Catalog. b. From the drop-down list box next to Among, select Selected Files. c. For the Replace with field, type GeneralCatalog. d. Select the Match Case check box. e. Select the Find Now button. f. Once the word is found, click the Replace All (All files) button. If you are asked about checking the files out, click the Yes to All button. Close this window when completed. 12.Right-click on the Catalog directory in the servlet directory, and select Rename. TypeGeneralCatalog for the new directory name. 13.Right-click on the.java files in this directory, and select Compile. You need to compile the Java beans first Linking the catalog pages Now that you have developed the catalog pages and tested them all to ensure that they work as expected, it is now time to link all pages together to create a catalog subsite. The final subsite will still not be pretty or have session management integrated into it, but it will show us the flow of the catalog. Open the catalog project by performing the following steps: 1. In the Studio Workbench, select File->Open Project. 2. Open the Catalog.wao file located inside the drive:\subsites\catalog directory. ABC Company Web site design and development 237

248 Merging the two input pages To merge the two input pages, perform these steps: 1. In the Studio Workbench, double-click on the viewallcatalogitemsinput.html file. This checks it out and opens it in the Page Designer. 2. In the Studio Workbench, double-click the viewbypricecatalogitemsinput.html file. This checks it out and opens it in thepagedesigner. 3. While viewing the viewbypricecatalogitemsinput.html file in the Page Designer, select Edit->Select All. 4. Select Edit->Copy. 5. Close the viewbypricecatalogitemsinput.html file. You should see the viewallcatalogitemsinput.html file. Put the cursor at the top of the page, and select Edit->Paste. The page should appear as shown in Figure 220. Figure 220. New viewallcatalogitemsinput.html page 6. Save this file, and exit the Page Designer. 7. In the Studio Workbench, right-click on the Catalog directory, and select the Check In option. 8. If you select View->Relations and click on the viewallcatalogitemsinput.html file, you should see that it now references to viewbypricecatalogitems.servlet and viewallcatalogitems.servlet. 9. Right-click on viewbypricecatalogitemsinput.html, andselectdelete. Make sure delete from disk is selected. Then, click the OK button. Repeat this process for the GeneralCatalog subsite Modifying the viewallcatalogitems.jsp page Complete the following steps: 1. Double-click on viewallcatalogitems.jsp. This checks out the file and opens it in Page Designer. 2. Where the Product ID heading is, delete it, and type Add item to shopping cart. 3. Delete the JSP tag in the body cell under the heading Add item to shopping cart. 238 Web Enabling AS/400 Applications with IBM WebSphere Studio

249 4. With the cursor in the cell under the heading Add item to shopping cart, select Insert->Form and Input Fields->Push Button->Submit Button. You are presented with the dialog shown in Figure 221. Figure 221. Insert push button dialog box 5. Complete the following parameters in the Push Button dialog box: a. In the Name field, type AddItem. b. In the Label field, type Add Item. c. Leave the Button Type set to Submit. 6. At this point, your page should look like the example shown in Figure 222. Figure 222. viewallcatalogitemsresults.jsp after being modified Now that you have modified your page, you need to decide what information you need to pass and to where. The good thing about using the Studio Wizards so far is that you have a reference page to look at for this information. Follow these steps: 1. Browse through the Studio Workbench, and double-click the file called viewcatalogitem.html to open it in the Page Designer. The page should look like the example in Figure 223 on page 240. ABC Company Web site design and development 239

250 Figure 223. viewcatalogitem.html viewed in the Page Designer 2. This page contains information of what servlet to call to view a single item and what parameters that servlet takes. Double-click inside the text field next to Product ID. You should see the dialog box shown in Figure 224. Figure 224. ProductID attribute dialog box 3. Make note of the name of this text field. This text field is called prodid. You will need this information later. Click the Cancel button. 4. Get the information about the servlet that you are calling. Double-click inside the text field next to the Product ID label. You will see the same dialog box as before. However, if you click in the drop-down list box next to the Tag caption, you see the caption Form listed in the list box. Select this, so we can see the properties of the form. The dialog box should look like the example shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

251 Figure 225. Product ID form attribute dialog box 5. The parameter that we need to observe in Figure 225 is Action. Make a note of where this action points to, which is /servlet/catalog.viewcatalogitem. This is the location of the servlet. Submitting the form by clicking the Submit button, all form parameters are sent to the servlet. Now that you have this information, you can return back to the viewallcatalogitemsresults.jsp page, which should still be open in the Page Designer. If it is not opened, double-click the file in the Studio Workbench. Follow these steps: 1. Double-click the Add Item button you added last to this page. 2. You are presented with the button dialog box. We want the form properties, so click in the drop-down list box next to Tag, and select Form. 3. The Form properties should be blank. You are now going to use the information from before for this form. For the action, type: /servlet/catalog.viewcatalogitem. 4. Set the method to Post. The resulting form properties may look like the example in Figure 226 on page 242. ABC Company Web site design and development 241

252 Figure 226. Form attribute dialog box 5. You now need to add some parameters to the form Hidden Fields. These fields allow us to pass parameters from one form to a servlet without the user having to type anything. Click on the Hidden Fields tab. You should see the dialog box shown in Figure 227. Figure 227. Form attribute dialog box showing Hidden Fields 242 Web Enabling AS/400 Applications with IBM WebSphere Studio

253 Note The hidden fields can still be viewed by a user if they look at the source of the HTML documentation. The hidden fields should Never contain a user s password or confidential information. In our example, we are not too worried if the user finds out their customer number because they cannot do much with it unless they login successfully. 6. You need to add a hidden field to represent the product ID. Click in the Name field, and type prodid. 7. For the value of this parameter, you need to specify it from a bean property. Under the Value field, select the Specify by property check box. 8. Click the Browse... button under the Value field. You should see a dialog box like the one in Figure 228. Figure 228. Bean property selection dialog box 9. We need the product ID, so select APILIB_ITEM_IID(). Click the OK button. 10.In the Attribute window on the Hidden Fields tab, click the Add button to add this parameter. 11.Click the OK button, save your page, and quit Page Designer. 12.Check in all your files in the Studio Workbench. 13.Publish only the modified files. Repeat the process from in this section for the viewbypricecatalogitemsresults.jsp page Adding an item from the catalog You need to modify the viewcatalogitemresults.jsp page so that you can call the addtocart servlet. Follow these steps: 1. Double-click the viewcatalogitemresults.jsp file. This checks it out and opens it in the Page Designer. The page should appear as shown in Figure 229 on page 244. ABC Company Web site design and development 243

254 Figure 229. viewcatalogitemresults.jsp page 2. Right-click in the first column, and select Delete. Repeat this in all the cells. 3. We are now left with two JSP tags. Place the cursor between these two tags, and select Insert->Table. Set the columns to 1 and the rows to Double-click inside the table. You should get the table Attribute dialog box. 5. Click the Table tab, and deselect the show border check box. 6. Click the Dynamic tab, and click inside the loop check box. For the loop property, click the Browse... button, and select for the loop property APILIB_ITEM_IID(). Click the OK button. 7. Click the OK button inside the Attribute dialog box. 8. Place the cursor inside the table and select Insert->Form and Input Fields->Form. Click the OK button in the form Attribute dialog box. 9. Inside the form, type the following text: Product ID - Product name - Product unit price - Product quantity - 10.We need to display the dynamic properties from the bean. Place the cursor at the end of the line that has the text Product ID -. Select Insert->Dynamic Elements->Property Display. You then see the dialog box shown in Figure 230. Figure 230. Dynamic elements Attribute dialog box 11.Click the Browse... button. In the Bean Property Selection dialog box, select the property APILIB_ITEM_IID(), and click the OK button. 244 Web Enabling AS/400 Applications with IBM WebSphere Studio

255 12.Click the OK button in the Attribute dialog box. 13.Repeat the above process for the Product name caption using APILIB_ITEM_INAME(). 14.Repeat the above process for the Product unit price caption using APILIB_ITEM_IPRICE(). 15.Place the cursor next to the Product quantity caption, and select Insert->Form and Input Fields->Text Field. In the Text Field Attribute dialog box, click the OK button. 16.Add two lines under the Product quantity caption, and select Insert->Form and Input Fields->Push Button->Submit button. In the name field, type additem and in the Label field, type Add to Shopping Cart. Click the OK button. The viewcatalogitemresults.jsp page should appear as shown in Figure 231. Figure 231. Modified viewcatalogitemresults.jsp page We want this page to replace addtocartinput.html, so you need to determine what parameters are passed to which servlet. Follow these steps: 1. In the Studio Workbench, double-click the addtocartinput.html file. This checks out the file and opens it in Page Designer. The page should appear as shown in Figure 232. Figure 232. Getting the addtocartinput.htm parameters 2. Double-click in the field next to Customer ID. Note the name in the Text Field dialog box, which should be custid. Click the Cancel button. ABC Company Web site design and development 245

256 3. Repeat the previous process on the field next to Product Name. The Text Field name should be prodname. 4. Repeat the process on the field next to Product ID. The Text Field name should be prodid. 5. Repeat the process on the field next to Product price. The Text Field name should be prodprice. 6. Repeat the process on the field next to Prod Quantity. The Text Field name should be prodqty. 7. Double-click inside the form to get the Form attribute dialog box. Note the action for this form, which, in this case, is /servlet/catalog.addtocart. We now return to the viewcatalogitemsresults.jsp page to use the parameters from the previous process. Follow these steps: 1. In the Studio Workbench, double-click on the ViewCatalogItemsResults.jsp page. This checks out the file and opens it in Page Designer. 2. Double-click inside the form area. You should get the Form Attribute dialog box. For the Action, type: /servlet/catalog.addtocart 3. Set the method to Post. 4. Click the Hidden Fields tab and add the hidden fields listed in Table 25. Table 25. Hidden field properties for viewcatalogitemsresults Hidden field name Hidden field bean source prodname prodid prodprice viewcatalogitemdbbean.apilib_item_iname() viewcatalogitemdbbean.apilib_item_iid() viewcatalogitemdbbean.apilib_item_iprice() 5. Double-click on the text field next to the Product Quantity caption. In the Text field dialog box, type prodqty for the name, and click the OK button. 6. Save this page, and exit the Page Designer. 7.4 Shopping cart subsite The shopping cart subsite allows the user to work with their shopping cart. There are several ways in which the user could work with their shopping cart, but for this book, we have limited it to viewing, deleting, andchanging item quantities Creating the shopping cart project We need to create a new project for the shopping cart subsite. Follow these steps to create the new Shopping Cart project folder: 1. Start WebSphere Studio if it is not already started. 2. Create the new project by selecting File->New Project. 3. Type ShoppingCart for the project name. 4. Type drive:\subsites\shoppingcart for the project folder. 5. Select <none> for project template. 246 Web Enabling AS/400 Applications with IBM WebSphere Studio

257 A new project is created called ShoppingCart Creating the SQL queries for the shopping cart subsite Before beginning this section, you should already be familiar with the SQL Wizard discussed in 3.2, Studio Wizards on page Selecting all items from the shopping cart Perform the following tasks that run the SQL Wizard to create an SQL statement that selects all items from the shopping cart: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Shopping Cart. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information described in Table 26. Table 26. Creating a select all query for the shopping cart Tabbed window Action explanation Welcome Enter viewallshoppingcart as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click on the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which isapilib in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. ABC Company Web site design and development 247

258 Tabbed window Action explanation Join No action is required. Click Next. Columns Click the Select All button. Then, click the Add >> buttontoadd the columns in the list box. Click Next. Condition 1 Select SCID in the Columns list box. Select the operator as is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name custid, and then click OK. Click Next. Sort You need to display all the products based on the order of the product ID. Click on APILIB.SHPCART.SIID. Click the Add >> buttontoadd it to the columns to sort on list box. Make sure the sort order is set to Ascending. Click Next. SQL At this point, you should have some test data in your shopping cart table. Click the Run SQL... button, and type This should give you all the items for that particular customer. Click the OK button on the SQL Execution Result Set window. Click Next. Finish Click the Finish button. The completed SQL file should appear in the project as viewallshoppingcart.sql. 5. Check in the generated file viewallshoppingcart.sql to the Studio Workbench. Select the ShoppingCart folder. Then, right-click, and select the Check In option Selecting a single item from the shopping cart Perform the following tasks that run the SQL Wizard to create an SQL statement that selects a single item from the shopping cart: 1. Start WebSphere Studio it is if not already started. 2. Select the project folder Shopping Cart. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 248 Web Enabling AS/400 Applications with IBM WebSphere Studio

259 4. Proceed through the tabbed windows of the wizard, and specify the information described in Table 27. Table 27. Creating a select single item query for the shopping cart Tabbed window Welcome Action explanation Enter viewshoppingcartitem as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which isapilib in this case. Click on the library to select it, and click the Add button. Click the OK button to return to the Tables window. Click the Select radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. Join No action is required. Click Next. Columns Click the Select All button. Then, click the Add >> buttontoadd the columns in the list box. Click Next. ABC Company Web site design and development 249

260 Tabbed window Condition 1 Action explanation Select SCID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name custid, and then click the OK button. Click the Find on another column button. Condition 2 Make sure the radio button Find fewer rows (AND) at the top is selected. Select SIID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click on the Parameter button. In the Create a new parameter dialog box, enter the variable name productid, and click the OK button. Click Next. Sort No action is required. Click Next. SQL You should now see your SQL statement. To test if it works correctly, click the Run SQL... button. You are now prompted for two parameters in the Specify Parameter Value(s) window. For the first parameter, type Now, type a product ID xxxx. After running this SQL statement, the result should be a single product. Click Next. Finish Click Finish. The completed SQL file should appear in the project as viewshoppingcartitem.sql. 5. Check in the generated file viewshoppingcartitem.sql to the Studio Workbench. Select the ShoppingCart folder. Then, right-click, and select the Check In option Updating a single item in the shopping cart Perform the following tasks that run the SQL Wizard to create an SQL statement that updates a single item in the shopping cart: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Shopping Cart. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 250 Web Enabling AS/400 Applications with IBM WebSphere Studio

261 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 28. Table 28. Creating an update single item query for the shopping cart Tabbed window Welcome Action explanation Enter updateshoppingcartquantities as the name of the query. The wizard adds an.sql file in your project. Click Next. Logon Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid:user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Click the library to select it, and click the Add button. Click the OK button to return to the Tables window. Click the Update radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. Update Click in the SQTY value field and click the Parameter button. In the Modify an Existing Parameter window, type newqty, and click OK. Click Next. Condition 1 Select SCID in the Columns list box. Select the operator as is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name custid, and click OK. Click Find on another column. ABC Company Web site design and development 251

262 Tabbed window Condition 2 Action explanation Make sure the radio button Find fewer rows (AND) at the top is selected. Select SIID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name productid, and click OK. Click the Next button to go to the next tab. SQL Click the Run SQL... button, and type 0011 for the first parameter and xxxx for the product ID. Enter in some value for newqty. You should find that the shopping cart is now updated with the new quantity. Click the OK button on the SQL Execution Result Set window. Click Next. Finish Click Finish. The completed SQL file should appear in the project as updateshoppingcartquantities.sql. 5. Check in the generated file updateshoppingcartquantities.sql to the Studio Workbench. Select the ShoppingCart folder. Then, right-click, and select the Check In option Deleting a single item from the shopping cart Perform the following tasks that run the SQL Wizard to create an SQL statement that deletes a single item in the shopping cart: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Shopping Cart. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 29. Table 29. Creating a delete single item query for the shopping cart Tabbed window Action explanation Welcome Enter deleteshoppingcartitem as the name of the query. The wizard adds an.sql file in your project. Click Next. 252 Web Enabling AS/400 Applications with IBM WebSphere Studio

263 Tabbed window Logon Action explanation Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click on the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which isapilib in this case. Click on the library to select, it and click the Add button. Click OK to return to the Tables window. Click the Delete radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. Condition 1 Select SCID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name custid, and click OK. Click Find on another column. Condition 2 Make sure the radio button Find fewer rows (AND) at the top is selected. Select SIID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name productid, and click the OK button. Click Next. ABC Company Web site design and development 253

264 SQL Tabbed window Action explanation Click the Run SQL... button, and type 0011 for the first parameter and xxxx for the product ID. You should now find that the shopping cart does not have that particular entry anymore. Click the OK button on the SQL Execution Result Set window. Click Next. Finish Click Finish. The completed SQL file should appear in the project as deleteshoppingcartitem.sql. 5. Check in the generated file deleteshoppingcartitem.sql to the Studio Workbench. Select the ShoppingCart folder. Then, right-click, and select the Check In option Creating Web pages for the shopping cart subsite Before beginning this section, you should already be familiar with the Database Wizard which is discussed in 3.2, Studio Wizards on page Displaying all items from the shopping cart Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select all records from the SHPCART database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder ShoppingCart. 3. Start the SQL Wizard by selecting Tools ->Wizards ->Database Wizard. 4. Select the appropriate SQL Statement, which you created in , Selecting all items from the shopping cart on page 247. It should be drive:\subsites\newuser\viewallshoppingcart.sql. 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 30. Table 30. Using the Database Wizard to display all shopping cart items Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. 254 Web Enabling AS/400 Applications with IBM WebSphere Studio

265 Tabbed window Input Page Action explanation The custid parameter should already be selected. Click the custid row and click the Change... button. In the Change Details dialog box, change the caption to Customer ID. Ensure that the Table radio button is selected. Click Next. Results Page The results page will already have the output parameters you wanted in the SQL file. These should be APILIB_SHPCART_SCID, APILIB_SHPCART_SDSC, APILIB_SHPCART_SQTY, APILIB_SHPCART_SPRC, and APILIB_SHPCART_SIID. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Perform this for the following parameters: For SCID, type Customer ID For SDSC, type Product Name For SQTY, type Product Quantity For SPRC, type Product Unit Price For SIID, type Product ID Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session This bean is only to be used one time. You do not need to bind it to the session so make sure No is selected. Name the bean viewallshoppingcartdbbean. Click Next. ABC Company Web site design and development 255

266 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type viewallshoppingcart into the Prefix dialog. Click OK. Note that all of the files now have the prefix of viewallshoppingcart. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following files added to the Studio Workbench: viewallshoppingcarterror.jsp viewallshoppingcartinput.html viewallshoppingcartnodata.jsp viewallshoppingcartresults.jsp 7. Select the ShoppingCart folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files have been created: viewallshoppingcart.class viewallshoppingcart.java viewallshoppingcart.servlet viewallshoppingcartdbbean.class viewallshoppingcartdbbean.java Displaying a single item from the shopping cart Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select a single record from the SHPCART database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder ShoppingCart. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL statement, which you created in , Selecting a single item from the shopping cart on page 248. It should be drive:\subsites\newuser\viewshoppingcartitem.sql. 5. Click Next. 256 Web Enabling AS/400 Applications with IBM WebSphere Studio

267 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 31. Table 31. Using the Database Wizard to display a single shopping cart item Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The user needs to be able to search by a price range, so make sure custid and productid check boxes are both selected. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Perform this for the following parameters: For customerid, type Customer ID For productid, type Product ID Ensure that the Table radio button is selected. Click Next. Results Page The results page will already have the output parameters you wanted in the SQL file. These should be APILIB_SHPCART_SCID, APILIB_SHPCART_SDSC, APILIB_SHPCART_SQTY, APILIB_SHPCART_SPRC, and APILIB_SHPCART_SIID. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Perform this for the following parameters: For SCID,typeCustomer ID For SDSC, typeproduct Name ForSQTY,typeProduct Quantity ForSPRC,typeProduct Unit Price ForSIID,typeProduct ID Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. ABC Company Web site design and development 257

268 Tabbed window Session Action explanation This bean is only to be used one time. You do not need to bind it to the session so make sure No is selected. Name the bean viewshoppingcartitemdbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button and type viewshoppingcartitem into the Prefix dialog. Click OK. Note that all of the files now have the prefix of viewshoppingcartitem. Click the Finish button to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following files added to the Studio Workbench: viewshoppingcartitemerror.jsp viewshoppingcartiteminput.html viewshoppingcartitemnodata.jsp viewshoppingcartitemresults.jsp 7. Select the ShoppingCart folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files have been created: viewshoppingcartitem.class viewshoppingcartitem.java viewshoppingcartitem.servlet viewshoppingcartitemdbbean.class viewshoppingcartitemdbbean.java Displaying the updated item in the shopping cart Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select the updated record from the SHPCART database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder ShoppingCart. 3. Start the SQL Wizard by selecting Tools ->Wizards ->Database Wizard. 4. Select the appropriate SQL statement, which you created in , Updating a single item in the shopping cart on page 250. It should be drive:\subsites\newuser\updateshoppingcartquantities.sql. 258 Web Enabling AS/400 Applications with IBM WebSphere Studio

269 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 32. Table 32. Using the Database Wizard to update a single shopping cart item Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. Click Next. Input Page The user needs to be able to search by price range, so make sure the newqty, custid, and productid check boxes are selected. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Perform this step for the following parameters: For customerid, type Customer ID For productid, type Product ID For newqty, type New Input Quantity Ensure that the Table radio button is selected. Click Next. Results Page For this test purpose, you only need one field selected to represent the output. This is just a sample output, so you can see if something happened in the testing stage. Select custid by clicking in the check box. Click the Change button, and type Customer ID as the new caption. Ensure that the Table radio button is selected. Click the Next button to go to the next tab. Standard Error Page Methods Click Next. Make sure that the method named execute() is selected. Click Next. Session This bean is only to be used one time. You do not need to bind it to the session so make sure No is selected. Name the bean updateshoppingcartquantitiesdbbean. Click Next. ABC Company Web site design and development 259

270 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type updateshoppingcartquantities into the Prefix dialog. Click OK. Note that all of the files now have the prefix of updateshoppingcartquantities. Click the Finish button to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. You should now see the following files added to the Studio Workbench: updateshoppingcartquantitieserror.jsp updateshoppingcartquantitiesinput.html updateshoppingcartquantitiesnodata.jsp updateshoppingcartquantitiesresults.jsp 7. Select the ShoppingCart folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you also see that the following files have been created: updateshoppingcartquantities.class updateshoppingcartquantities.java updateshoppingcartquantities.servlet updateshoppingcartquantitiesdbbean.class updateshoppingcartquantitiesdbbean.java Verifying a deleted item from the shopping cart Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to verify that a deleted record has been removed from the SHPCART database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder ShoppingCart. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL Statement, which you created in , Deleting a single item from the shopping cart on page 252. It should be drive:\subsites\newuser\deleteshoppingcartitem.sql. 5. Click Next. 260 Web Enabling AS/400 Applications with IBM WebSphere Studio

271 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 33. Table 33. Using the Database Wizard to delete a single shopping cart item Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. Click Next. Input Page The user needs to be able to search by price range, so make sure the custid and productid check boxes are both selected. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Perform this step for the following parameters: For customerid, type Customer ID For productid, type Product ID Ensure that the Table radio button is selected. Click Next. Results Page For this test purpose, you only need one field selected to represent the output. This is just a sample output, so you can see if something happened in the testing stage. Select custid by clicking in the check box. Click the Change button, and type Customer ID as the new caption. Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Click Next. Make sure that the method named execute() is selected. Click Next. Methods This bean is only to be used one time. You do not need to bind it to the session so make sure No is selected. Name the bean deleteshoppingcartitemdbbean. Click Next. ABC Company Web site design and development 261

272 Tabbed window Session Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type deleteshoppingcartitem to the Prefix dialog. Click OK. Note that all of the files will now have the prefix of deleteshoppingcartitem. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. Finish This tab allows you to specify what HTML and JSP files will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. Click Next. You should now see the following files added to the Studio Workbench: deleteshoppingcartitemerror.jsp deleteshoppingcartitem.html deleteshoppingcartitemnodata.jsp deleteshoppingcartitemresults.jsp 7. Select the ShoppingCart folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files have been created: deleteshoppingcartitem.class deleteshoppingcartitem.java deleteshoppingcartitem.servlet deleteshoppingcartitemdbbean.class deleteshoppingcartitemdbbean.java Testing the shopping cart pages Now that the shopping cart pages have been built you should test them to see if the results are what you want. It is much easier to fix the pages at this point if there is a problem. Follow these steps: 1. Make sure your publishing target is setup. Refer to 4.3.1, Publishing to the AS/400 system on page 125, if you have not done this yet. 262 Web Enabling AS/400 Applications with IBM WebSphere Studio

273 2. Right-click on the ShoppingCart project folder in the Studio Workbench. Select Publish whole Project. This publishes the entire Catalog project to your defined server, which is an AS/400 server in our case. 3. Once you have published your Web pages, make sure your WebSphere Application Server and Web server are both started Retrieving all items from the shopping cart To test retrieving all items from the shopping cart, perform the following steps: 1. Select the viewallshoppingcartinput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 233. Figure 233. viewallshoppingcartinput.html displayed in Netscape 2. Type a valid customer ID from the SHOPCART table. For this example, we use customer ID Click the Submit button. The result page should appear as shown in Figure 234. Figure 234. viewallshoppingcartresults.jsp displayed in Netscape Notice that we only have the output for that single customer ID. When looking at this screen, you can see that there is information that we do not really want to present to the user. The user does not really need to see their customer ID or the ABC Company Web site design and development 263

274 product ID of all the products. They only really need to see product name, price, and quantity. You see the customer ID and product ID because we select to have these values in the output. It is important to have these values selected for the output so the bean has all the getters and setters automatically created. It becomes much clearer why we need these later in this section Retrieving a single item from the shopping cart To test retrieving a single item from the shopping cart, perform the following steps: 1. Select the viewshoppingcartiteminput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 235. Figure 235. viewshoppingcartiteminput.html displayed in Netscape 2. Type a valid customer ID from the SHPCART table and a product ID that belongs to that customer ID. You can get this information from viewallshoppingcartresults.jsp. For this example, we use customer ID 0011 and product ID Click Submit. The result page should appear as shown in Figure 236. Figure 236. viewallshoppingcartresults.jsp displayed in Netscape 264 Web Enabling AS/400 Applications with IBM WebSphere Studio

275 Notice that we only have the output for that single customer ID and product ID. Again, you can see that we have excess information, but we deal with this later in this chapter Updating an item quantity in the shopping cart To test updating an item quantity in the shopping cart, perform the following steps: 1. Select the updateshoppingcartquantitiesinput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 237. Figure 237. updateshoppingcartquantitiesinput.html displayed in Netscape 2. Type in a valid customer ID from the SHPCART table and a product ID that belongs to that customer ID. You can get this information from viewallshoppingcartresults.jsp. For this example, we use customer ID 0011 and product ID Add an item quantity that is different to what this product has. For this example, the new quantity is set to Click Submit. The result page should appear as shown in Figure 238. Figure 238. updateshoppingcartquantitiesresults.jsp displayed in Netscape ABC Company Web site design and development 265

276 Notice that the returned information does not give us any feedback. But, for this example, we needed some form of feedback to know if the update worked or failed. If the update fails, we see the error page. To check if the update was successful, check the SHPCART table on the AS/400 system, or you can preview the viewallshoppingcart.html and enter the same customer ID as before Verifying a deleted item from the shopping cart To test if a deleted item has been removed from the shopping cart, perform the following steps: 1. Select the deleteshoppingcartiteminput.html file to preview it. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 239. Figure 239. deleteshoppingcartiteminput.html displayed in Netscape 2. Type in a valid customer ID from the SHPCART table and a product ID that belongs to that customer ID. You can get this information from viewallshoppingcartresults.jsp. For this example, we use customer ID 0011 and product ID Click Submit. The result page should appear as shown in Figure 240. Figure 240. deleteshoppingcartresults.jsp 266 Web Enabling AS/400 Applications with IBM WebSphere Studio

277 Notice that the returned information does not give us any feedback. But, for this example, we need some form of feedback to know if the delete worked or failed. If the delete fails, we see an error page. To check if the delete has was successful, check the SHPCART table on the AS/400 system, or you can preview the viewallshoppingcart.html and enter in the same customer ID as before Modifying the shopping cart bean to display item totals It was mentioned earlier when we were looking at the output screen of the viewallshoppingcart that it would be nice to have some item totals. To do this, we need to modify the Java Bean and the.jsp Modifying the bean Perform the following steps to modify the bean in order to display item totals: 1. In the Studio Workbench, click the plus sign (+) nexttotheservletdirectory. 2. In the servlet directory, click the ShoppingCart directory. 3. Locate the file called viewallshoppingcartdbbean.java. Double-click this file. You will be prompted with the dialog box shown in Figure 241. Figure 241. Check-out file with dependencies 4. Click the Check Out and Edit button. You are now presented with a text editor with your JavaBean source code in it. We need to add a method to this bean which returns the totals each time a row is processed. 5. Find where setcustid is in the bean and move the cursor to the next line. Insert the following code: /******************************************************************* * Get method for the total price per item the value of the total price per item */ public java.math.bigdecimal gettotalitemprice(int index) ABC Company Web site design and development 267

278 { return (java.math.bigdecimal) getapilib_shpcart_sprc(index).multiply(getapilib_shpcart_sqty(index)); } The above code adds a getter to the bean that allows you to retrieve the entire total for that item of the shopping cart. 6. Save this bean and close the code. You now need to recompile the bean so the class file is up to date. 7. Right-click the ShoppingCart root directory. Select Check In. 8. Right-click the viewallshoppingcartdbbean.java. Select Compile. 9. You are presented with a warning dialog box like the example in Figure 242 asking if you wish to check out the.class too. Click Yes To All. Figure 242. Check-out files Warning dialog box 10.Right-click on the ShoppingCart root directory, and select Check In Modifying the Shopping Cart Results page Now that we have the new getter added to our bean and the source code has been compiled, we need some way in which we can add this to our Shopping Cart JSP page. Perform the following steps to add item totals to the Shopping Cart page: 1. Double-click the viewallshoppingcartresults.jsp. This checks the file out and opens it in Page Designer. Your page should look like the example in Figure 243. Figure 243. viewallshoppingcartresults.jsp before modification 268 Web Enabling AS/400 Applications with IBM WebSphere Studio

279 2. To add the bean property that you created, you need to add a new column to the table. Click in the ProductID column. Select Table->Add Column->Add to the Right of Cell. 3. You can now see that another column has been added to the table. In the top cell of this new column, type the caption Total Unit Price. 4. Click in the bottom cell of this new column. 5. Insert the new bean property. Select Insert->Dynamic Elements->Property Display... You are presented with the dialog box shown in Figure 244. Figure 244. Property display attribute dialog box 6. Click the Browse button so you can select the property that you want to display. You should see a dialog box like the one shown in Figure 245. Figure 245. Bean property selection dialog box 7. Select the totalitemprice() getter to get back the total item price which is quantity multiplied by unit price. Click OK to continue. 8. viewallshoppingcartdbbean.totalitemprice() should appear in the Property text field in the Attribute window. Click OK to continue. 9. You should now see your page with the extra column and the newly added JSP tag. The page should appear as shown in Figure 246 on page 270. ABC Company Web site design and development 269

280 Figure 246. viewallshoppingcartresults.jsp with total unit price 10.Save your new results page, and close the Page Designer. 11.Right-click the ShoppingCart root directory, and select Check In. You now need to re-publish the updated files so as you can test the output of your new Shopping Cart results page: 1. Right-click the ShoppingCart root directory, and select Publish whole Project. 2. You would have seen the dialog box shown in Figure 247 before but, this time, we only want to publish modified files. Select the check box next to Publish only modified files. Click OK. Figure 247. Publishing options set to publish only modified files 3. You may be presented with a dialog box that asks if you want to replace some files. Click Yes. Now that you have published these new files, you should be ready to look at the resulting page. 270 Web Enabling AS/400 Applications with IBM WebSphere Studio

281 4. Right-click viewallshoppingcartinput.html, and select Preview File with ->Netscape. You are presented with the same input page you saw earlier in this section. 5. Type a customer ID that you know exists in the database. After you click the Submit button, you should be presented with a results page that looks like the example in Figure 248. Figure 248. Displaying the updated viewallshoppingcartresults.jsp page in Netscape Linking the shopping cart pages Now that we have developed the shopping cart pages and tested them all to ensure that they work as expected, it is time to link all pages together to create a shopping cart subsite. The final subsite will still not be pretty or have session management integrated in to it, but it will show us the flow of the shopping cart. The flow that we want to achieve here is to view the full shopping cart for one customer ID and have the user be able to select an individual item for editing or deleting Modifying the viewallshoppingcartresults.jsp page Perform the following tasks to modify the Shopping Cart results page: 1. Double-click the viewallshoppingcartresults.jsp. This checks out the file and opens it in Page Designer. 2. You need to add a way of getting information from each row from this page to the viewshoppingcartitem page. Click the Total Unit Price heading, and select Table->Add Column->Add to the Right of Cell. 3. In the top cell of the new column, type Work With Item. 4. In the bottom cell of the new column, you need to add a form and a button. Select Insert->Form and Input Fields->Push Button->Submit Button. You are presented with the dialog box shown in Figure 249 on page 272. ABC Company Web site design and development 271

282 Figure 249. Push button attribute dialog box 5. For the parameters, set Name to edititem and Label to Edit Item. Leave Button Type set to Submit. Click OK. Your page should look like the example in Figure 250. Figure 250. viewallshoppingcartresults.jsp with modifications Now that we have modified our page, we need to decide what information we need to pass and to where we need to pass it. Follow these steps: 1. Browse through the Studio Workbench, and find the file called viewshoppingcartiteminput.html. Double-click this file to open it in Page Designer. It should look like the display in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

283 Figure 251. viewshoppingcartiteminput.html 2. This page contains information about what servlet to call to view a single item and what parameters the servlet takes. Double-click inside the text field next to Customer ID. You should see the dialog box shown in Figure 252. Figure 252. Text field attribute dialog box 3. Make note of the name of this text field. This text field is called custid. You will need this information later. Click Cancel. 4. Do the same again for the text field next to Product ID. You see that the text field name is productid. Again, you will need this information later. 5. Get the information about which servlet this page calls. Double-click inside the textfieldnexttothecustomer ID label. You will see the same dialog box as before but, if you click in the drop-down list box next to Tag, you see the caption Form in the list box. The form attribute dialog box should look like the display in Figure 253 on page 274. ABC Company Web site design and development 273

284 Figure 253. Form attribute dialog box 6. The parameter that you need to observe Figure 253 is Action. Makeanoteof where this action points to, which is /servlet/shoppingcart.viewshoppingcartitem. Now that we have this information, we can return to the viewallshoppingcartresults.jsp page, which should still be open in the Page Designer. If it is not opened, double-click the file in the Studio Workbench. Follow these steps: 1. Double-click the Edit button you added last to this page. 2. You are presented with the button dialog box. You want the form properties so click in the drop-down list box next to Tag, and select Form. 3. The Form properties should be blank. For Action, type: /servlet/shoppingcart.viewshoppingcartitem 4. Set Method to Post. The resulting form properties should appear as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

285 Figure 254. Form attribute dialog box 5. You now need to add some parameters to the forms hidden fields. Click the Hidden Fields tab. You should see a dialog box like the example in Figure 255. Figure 255. Form attribute dialog box showing hidden fields ABC Company Web site design and development 275

286 Hidden fields The hidden fields can still be viewed by a user if they look at the source of the HTML documentation. The hidden fields should never contain a user s password or confidential stuff. In our example, we are not too worried if they find out their customer number because they cannot do much with it unless they login successfully. 6. You need to add two hidden fields. The first hidden field represents the customer ID. Click the Name field, and type custid. 7. For the value of this parameter, specify it from a bean property. Under the value field, select the check box called Specify by property. 8. Click the Browse... button under the Value field. You should see a dialog box like the example in Figure 256. Figure 256. Bean property selection dialog box 9. Select the customer ID property, APILIB_SHPCART_SCID(). Now,clickOK. 10.In the Attribute window on the Hidden Fields tab, click Add to add this parameter. 11.Repeat this process for adding the productid variable. In the Name field, type productid. 12.Under the Value field, select the Specify by property check box. 13.Click the Browse button under the Value field, and select the APILIB_SHPCART_SIID() property. Click OK. 14.Click the Add button. 15.Your final Hidden Fields tabbed page should look like the example in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

287 Figure 257. Hidden fields dialog box for viewallshoppingcartresults.jsp 16.Click OK, save your page, and quit Page Designer. 17.Check all your files in the WebSphere Studio. 18.Publish only the modified files Testing the Shopping Cart page We are now ready to test the joining of these pages. When we run this test, we open the viewallshoppingcartinput.html file, and enter a customer ID value used earlier. We should then see our shopping cart with buttons in the far right-hand cell of the table. If we click one of these buttons, we should go to the viewshoppingcartitemresults.jsp and skip the input page for this. We are now dynamically passing variables from one page to another. Perform the following tasks to test the Shopping Cart page: 1. Right-click viewallshoppingcartinput.html. SelectPreview File With->Netscape. You should see the page shown in Figure 258. Figure 258. viewallshoppingcartinput.html displayed in Netscape ABC Company Web site design and development 277

288 2. Enter a customer ID for which you know there are shopping cart entries. Type Click Submit. You should see the page shown in Figure 259. Figure 259. viewallshoppingcartitemsresults.jsp displayed in Netscape 3. Click one of the Edit Item buttons. You should see the page shown in Figure 260. Figure 260. viewshoppingcartitemresults.jsp See how we have used the WebSphere Studio Wizards to generate the pages and then manually link them together. This makes the WebSphere Studio tools very powerful Changing the quantities of the items in the shopping cart Now that we have the two shopping cart pages linked together, we can edit the viewshoppingcartitemresults.jsp page so that we can edit and change quantities from our shopping cart Editing the Shopping Cart Item Results JSP Perform the following tasks to edit the Shopping Cart Item Results page to modify item quantities from the shopping cart: 278 Web Enabling AS/400 Applications with IBM WebSphere Studio

289 1. Double-click on viewshoppingcartitemresults.jsp. Thischecksoutthefile and opens it in Page Designer. 2. Looking at this page, you can see that there is a table with a dynamic property loop around the body cells. This is good if we have many items to display, but not for a single item. Unfortunately, the way the bean is generated from the Database Wizard requires a loop index parameter to access the results. We can think of this as a dummy loop that we know will only iterate through once. The page should appear like the example in Figure 261. Figure 261. viewshoppingcartitemresults.jsp before modification 3. You need to make this page look better for presenting a single item. Click the top line of the table so there is a pink border surrounding the table. This means the whole table has been selected. 4. Right-click the pink border, and select Delete. This removes the table, and you are left with two JSP tags. The first tag is to execute the bean and the second tag is to close the bean. 5. With the cursor between these two tags, press the Enter key a couple of times. This ensures that you do not get confused and accidently delete these tags. 6. You now need to insert a single cell table inside the dynamic loop. Go to Table->Insert Table Body In the Insert Table dialog box, set the columns to 1 and rows to 1. Click OK. 8. Double-click inside the table. Click the Table tabinthetableattributedialog box and deselect the check box Show border so the table becomes invisible. 9. Click the Dynamic tab. This tabbed window allows you to set dynamic loop properties for the table. Click the top loop check box. The direction does not matter. The dialog box should look like the display in Figure 262 on page 280. ABC Company Web site design and development 279

290 Figure 262. Dynamic loop attributes for a table 10.Click the Browse button. You should see the dialog box shown in Figure 263. Figure 263. Dynamic loop attribute dialog box 11.For the loop property, use the product ID. Click the Browse... button. The dialog box shown in Figure 264 should appear. 280 Web Enabling AS/400 Applications with IBM WebSphere Studio

291 Figure 264. Bean property selection dialog box 12.Click the plus sign (+) next to viewitemshoppingcartdbbean. This displays all the properties for viewitemshoppingcartdbbean. 13.Select the APILIB_SHPCART_SIID() property, and click OK. 14.Click OK in the Attribute window. 15.Add a form to this dynamic loop. Select Insert->Form and Input Fields->Form. 16.Inside this form, type: User Name :- Product Name :- Product Unit Price :- Product Quantity :- 17.Place the cursor next to User Name, and select Insert->Dynamic Elements->Property Display You should see the bean Attribute window. Click the Browse... button. 19.You now see the Bean Property Selection. Select APILIB_SHPCART_SIID(), and click OK. 20.Click the OK button in the Attribute window. 21.The JSP tag for this property is now added to the page. Your page should look like the display in Figure 265 on page 282. ABC Company Web site design and development 281

292 Figure 265. viewshoppingcartitemresults.jsp after slight modification 22.Repeat steps 17 through 20 using APILIB_SHPCART_SDSC() Bean Property Selection to get the Product Name. 23.Repeat steps 17 through 20 using APILIB_SHPCART_SPRC() Bean Property Selection to get the Product Name. 24.For the Product Quantity, use a text field so as this parameter can be changed. Place the cursor next to Product Quantity :- and go to Insert->Form and Input Fields->Text Field. 25.You are presented with a dialog box for the text field attributes. For now, click OK. You will return to the dialog box later. 26.Press Enter a couple of times after the text field. Click Insert->Form and Input Fields->Push Button->Submit Button. 27.You should see the Attribute window for the button. Give this button a name of updateqty and a caption of Update Item Quantity. 28.Click OK. The resulting page should appear as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

293 Figure 266. viewshoppingcartresults.jsp after modifications We have now completed the modifications to this page to view the information for a shopping cart item. Follow these steps: 1. Browse through the Studio Workbench and find the file called updateshoppingcartquantitiesinput.html. Double-click this file to open it in Page Designer. It should look like the display in Figure 267. Figure 267. updateshoppingcartquantitiesinput.html 2. To take the parameters from the text fields on this page and find out what servlet is being called from the form. Double-click inside the text field next to New Quantity. In the text field attribute window, note the name of the text field. In this case, it should be named newqty. Click the Cancel button. 3. Double-click in the field next to Customer ID. Again you should see the Attribute window. Make note of the name parameter which in should be custid. Click Cancel. 4. Double-click the field next to Product ID. You should see the Attribute window. Make note of the name parameter which should be productid. Click the Cancel button. ABC Company Web site design and development 283

294 5. Find the servlet to which this information is being sent. Double-click inside the form area. You will see an Attribute window, but it may not be looking at the form. Click in the drop-down list box next to the Tag caption. Select Form. Make a note of the Action parameter which is /servlet/shoppingcart.updateshoppingcartquantities. ClicktheCancel button. 6. You can now close this file in Page Designer. You now have all the information you need to go back and complete the Shopping Cart Item Results page. Now, follow these steps: 1. If it is not already open, double-click viewshoppingcartitemresults.jsp. This checks the file out and opens it in Page Designer. 2. You need to add the form parameters. Double-click in the text field next to Product Quantity. This opens the Attribute dialog box. 3. In the Attribute dialog box, set the name to be newqty sincethisisthevalue we want to update. 4. For the initial value, click the Specify by property check box located just under the Initial Value text field. 5. Click the Browse button just under the initial value text field to find the bean parameter to use here. 6. You see a Bean Property Selection window again. Select the property APILIB_SHPCART_SQTY(). Then, click OK. 7. In the Attribute window, click OK. 8. Double-click inside the form. If the form properties are not shown, click the drop-down list box next to the tag parameter, and select form. 9. For the action parameter, you need to specify the servlet to which this form will post its information. For the action, type: /servlet/shoppingcart.updateshoppingcartquantities 10.Click the radio button called Post to set the method. 11.Click on the Hidden Fields tabatthetopoftheattributewindow. 12.Click in the field next to the name caption, and type custid. 13.Click the Specify by Property check box under the value field, and then click the Browse button under the value field. 14.You should now see the Bean Property Selection dialog box. From here, select APILIB_SHPCART_SCID(). Then, click OK. 15.Click the Add button back in the Attribute window. 16.Follow steps 12 through 15, but use productid for the name of the hidden field and select APILIB_SHPCART_SIID(). Do not forget to click the Add button, otherwise the hidden field parameters will not be added. 17.Once you have completed this task, click OK. 18.Save this file, and close Page Designer. 284 Web Enabling AS/400 Applications with IBM WebSphere Studio

295 You now make one last change to the result page of the change quantity: 1. Double-click updateshoppingcartquantitiesresults.jsp to check it out and open it in Page Designer. The page should appear as shown in Figure 268. Figure 268. updateshoppingcartquantitiesresults.jsp 2. You can delete the entire contents of this page and write something slightly more meaningful. Select Edit->Select All, and then click Delete. 3. Type Your update was successful. 4. Save this page, and then exit Page Designer. 5. You can publish and test our pages. In the Studio Workbench, right-click on the ShoppingCart directory, and select Check In. Right-click again on the ShoppingCart directory, and select publish whole directory. Make sure the only publish modified files option is selected, and click OK. ClickYes for all prompts Testing the updated shopping cart for changing item quantities Perform the following tasks to test changing item quantities in the shopping cart: 1. In the Studio Workbench, select the file viewallshoppingcartinput.html and right-click on it. Select Preview File with->netscape. You should see the page shown in Figure 269. Figure 269. viewallshoppingcartinput.html displayed in Netscape ABC Company Web site design and development 285

296 2. Type a customer ID that is valid in your shopping cart table. We are using ClicktheSubmit button. You should see the page shown in Figure 270. Figure 270. viewallshoppingcartresults.jsp displayed in Netscape 3. Click the Edit Item button on any of the items shown. Go to the newly edited quantity page. This is the area you need to test. You should see a page similar to the example in Figure 271. Figure 271. viewshoppingcartitemresults.jsp displayed in Netscape 4. Change the quantity in the Product Quantity field. Try a value of 60. Click the Update Item Quantity button. You should see the page shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

297 Figure 272. updateshoppingcartquantitesresults.jsp displayed in Netscape Provided you see this final page, everything is working. You can check the table to see if the update has happened. You could look at the table through the View Shopping Cart Web page or look at the database table on the AS/400 system Deleting items from the shopping cart Now that we have the two shopping cart pages linked together, we can edit the viewshoppingcartitemresults.jsp page so that we can edit and delete items from our shopping cart Editing the Shopping Cart Item Results JSP Perform the following tasks to edit the Shopping Cart Item Results page to delete items from the shopping cart: 1. Double-click viewshoppingcartitemresults.jsp. This checks the file out and opens it in the Page Designer. You have already modified this page to change quantities, but now you need to add the ability to delete this item from the shopping cart. 2. Add a form in the bottom of the table below the update quantities form and before the end of the table. Select Insert->Form and Input Fields->Form. 3. While inside the new form that you have added, select Insert->Form and Input Fields->Push Button->Submit Button. 4. In the Attribute window, click OK. Now that we have added our new form, we need to get some input parameters and the servlet that we call to do the delete. Follow these steps: 1. Double-click deleteshoppingcartiteminput.html. This checks the file out and opens it in Page Designer. The page should appear as shown in Figure 273 on page 288. ABC Company Web site design and development 287

298 Figure 273. deleteshoppingcartiteminput.html 2. Double-click in the text field next to the caption Customer ID. In the Attributes dialog box, you should see that it is called custid. Make a note of this. Click the Cancel button. 3. Double-click in the text field next to the caption Product ID. In the Attributes dialog box, you should see that the name is called productid. Make a note of this, and click the Cancel button. 4. Double-click in the form to open the Forms Attribute dialog box. The action parameter should be /servlet/shoppingcart.deleteshoppingcartitem. Make a note of this, and click the Cancel button. We now have all the information we need to complete the Shopping Cart Item page. Follow these steps: 1. Open the viewshoppingcartitemresults.jsp page in Page Designer. 2. Double-click the Submit button that is down at the bottom of the page. This should give you the buttons attribute dialog box. 3. Type delete for the name, and type Delete for the label. 4. Select the form from the drop-down list box next to the tag caption. 5. For the action of this form, type: /servlet/shoppingcart.deleteshoppingcartitem. 6. Set the method to Post. 7. Click the Hidden Fields tab. 8. Type for the first hidden field custid. 9. For the value, click the Specify by Property button. 10.For the value, click the Browse... button. 11.Select from the bean property selector APILIB_SHPCART_SCID(). 12.Click the OK button. 13.Click the Add button. 288 Web Enabling AS/400 Applications with IBM WebSphere Studio

299 14.Repeat steps 8 through 13, but use product ID for the name of the hidden field, and select APILIB_SHPCART_SIIDC. Do not forget to click the Add button. Otherwise, the hidden field parameters will not be added 15.Click OK. The page should now look similar to the example in Figure 274. Figure 274. viewshoppingcartitemresults.jsp with the delete button added 16.Save this page and close Page Designer. We now make one last change to the result page of the change quantity. Follow these steps: 1. Double-click deleteshoppingcartresults.jsp to check it out and open it in the Page Designer. The page should appear as shown in Figure 275. Figure 275. deleteshoppingcartresults.jsp before modifications 2. You can delete the entire contents of this page and write something slightly more meaningful. Select Edit->Select All, and then click Delete. 3. Now, type Your delete was successful. ABC Company Web site design and development 289

300 4. Save this page, and then exit Page Designer. 5. Again, you need to check in all files in WebSphere Studio and publish only the modified files. Once this is done, you are ready for testing Testing the updated shopping cart for deleting items Perform the following tasks to test deleting items from the shopping cart: 1. In the Studio Workbench, select the file viewallshoppingcartinput.html and right-click on it. Select Preview File with->netscape. You should see the page shown in Figure 276. Figure 276. viewallshoppingcartinput.html displayed in Netscape 2. Type a customer ID that is valid in your shopping cart table. We are using ClicktheSubmit button. You should see the page shown in Figure 277. Figure 277. viewallshoppingcartresults.jsp 3. Click the Edit Item button on any of the items shown. Now, go to the newly edited quantity page. This is the area we need to test. You should see a page similar to the display in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

301 Figure 278. viewshoppingcartitemresults.jsp displayed in Netscape 4. Click the Delete button. You should see a final result page that looks like the example in Figure 279. Figure 279. deleteshoppingcartitemresults.jsp displayed in Netscape 5. Provided you see this final page, everything should have worked. You can check if the item has been deleted by looking at the shopping cart database table on the AS/400 system or by looking at the shopping cart again. 7.5 Creating the order purchase subsite The Purchase function, as represented on the ABC Company Web site, does not incorporate business logic to calculate available inventory, apply discounts, and place the order records into the company s enterprise database. As you recall from the earlier sections, we keep business logic with rules and policies inside existing server databases and applications, where we have proper and necessary data or information, security, and performance to conduct business transactions. Also, rewriting existing order processing and inventory management applications does not make a lot business sense. ABC Company Web site design and development 291

302 The order purchase function on the Web site processes shopping cart contents and packages them into parameters to be passed to the server program. The last step is to call the existing AS/400 server program. The AS/400 server program then takes over with order creation procedures. The server program we are referring to is not the servlet that packages and calls the RPG program, but the RPG program itself. Our servlets carry little or no business logic. In this particular example, the servlet knows how to package and submit the AS/400 RPG program. To develop order purchase functionality, we use Studio Wizards and Studio Page Designer tools. To completely achieve desired functionality, we alter Studio Wizards generated servlets, JSPs, and HTML files. The following is a conceptual representation of what it takes to submit an order: 1. Read the shopping cart contents. 2. Create order objects based on shopping cart contents (optional). 3. Package the order information into two strings to be passed to the AS/400 server program. 4. Call the AS/400 server program to process the order with existing applications. 5. Produce a confirmation page Creating the order purchase project To build the order purchase subsite, we need to create a new project. Follow these steps to create the new Order Purchase project folder: 1. Start WebSphere Studio if it is not already started. 2. Create a new project by selecting File->New Project from the pull-down menu. 3. Type OrderPurchase for the project name. 4. Type drive:\subsites\orderpurchase for the project folder. 5. Select <none> for project template. 6. Click OK. WebSphere Studio creates the folder \subsites\orderpurchase and the project file called OrderPurchase.wao. Within the project, WebSphere Studio also creates the servlet folder. To accomplish the task of submitting an order and mostly to rely on WebSphere Studio Wizards, we perform the following steps: 1. Create SELECT SQL for the SHPCART table, using the SQL Wizard. 2. Based on the SQL created in step 1, create a servlet, DB access bean, input HTML and JSPs, using the Database Wizard, to display the shopping cart and accept user entries for later submission of the order to be processed on the AS/400 server. 3. Modify the resulting JSP from step 2 using Page Designer to add the form to submit the order to the AS/400 server for further processing. 292 Web Enabling AS/400 Applications with IBM WebSphere Studio

303 4. Based on the SQL created in step 1, create a servlet, DB access bean, and JSPs, using the Database Wizard. In doing so, you package the shopping cart contents into parameters and call the RPG program to create the order on AS/400 server within existing enterprise database. 5. Write the Java code to retrieve the order information from the bean and to call the application program on the AS/400 system. Insert the code into the shopping cart retrieval servlet. 6. Create SELECT SQL for the ORDERS table, using the SQL Wizard, to retrieve the newly created order record. 7. Based on the SQL created in step 6, create a servlet, DB access bean, and JSPs, using the Database Wizard. In doing so, you display the resulting order record as confirmation of the successful order processing on AS/400 server. 8. Create DELETE SQL for the SHPCART table, using the SQL Wizard, to empty a shopping cart upon successful order processing. 9. Based on the SQL created in step 8, create a servlet, DB access bean, and JSPs, using the Database Wizard. In doing so, you delete the shopping cart contents upon successful order processing on the AS/400 server. 10.Combine the resulting JSPs from steps 4 and Creating SELECT SQL for the SHPCART table Perform the following tasks that run the SQL Wizard to create an SQL statement that selects all items from the shopping cart: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder Shopping Cart. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 34. Table 34. Information to be entered in the SQL Wizard Tabbed window Action explanation Welcome Enter selectcart as the name of the query. The wizard adds an.sql file in your project. Click Next. ABC Company Web site design and development 293

304 Logon Tabbed window Action explanation Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid:user ID Password: password Driver:AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user id and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click on the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. Join No action is required. Click Next. Columns Select only the SCID, SCSD, SIID, SPRC, and SQTY columns to be included in the output result. Click the Add button. Click Next. Condition 1 Specify SCID to be equal to the cust parameter. Note: The cust parameter is passed to the servlet. Click Next. Sort No action is required. Click Next. 294 Web Enabling AS/400 Applications with IBM WebSphere Studio

305 SQL Tabbed window No action is required. Action explanation This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clicking the Run SQL button. Click Next. Finish Click Finish. The completed SQL file should appear in the project as selectcart.sql. 5. Check the generated file selectart.sql into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option Creating servlet and DB access bean for SHPCART select query In this section, we create the servlet and the DB access bean to get the result of SHPCART select query, which should return the shopping cart contents found for the particular customer CSTMR. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderPurchase. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL Statement, which you created in 7.5.2, Creating SELECT SQL for the SHPCART table on page 293. It should be drive:\subsites\orderpurchase\selectcart.sql. 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 35. Table 35. Information to be completed in the Database Wizard Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The input page does not require any parameters. Click Next. ABC Company Web site design and development 295

306 Tabbed window Results Page Action explanation The results page already has the output parameters you wanted from the SQL file. These should be SDSC, SPRC, and SQTY. Select the parameters by clicking on the row. Click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For SDSC, type Product Description For SPRC, type Product Price For SQTY, type Product Quantity Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session There is really no need to store this bean in the session. This bean will be used just to display shopping cart contents and collect other information from the user. Make sure No is selected. Name the bean cartselectdbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button, and type cartselect into the Prefix dialog. Click OK. Note that all of the files now have the prefix of cartselect. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 7. Check all of the generated files (all files having the cartselect prefix) into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option. 8. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page Web Enabling AS/400 Applications with IBM WebSphere Studio

307 Unit testing the shopping cart contents retrieval Now that the Order Purchase Web page has been built, we should test it to see if the results are what we want. It is much easier to fix the pages at this point if there is a problem. Perform the following steps to test the order purchase subsite: 1. To perform the unit test, make sure the SHPCART table is not empty. Refer to 7.4, Shopping cart subsite on page 246, for an explanation on creating and populating the shopping cart table with sample records. 2. Make sure you have your publishing target setup. Refer to 4.3.1, Publishing to the AS/400 system on page 125, if you have not done this yet. 3. Right-click on the OrderPurchase project folder in the Studio Workbench and select Publish whole Project. This publishes the entire Catalog project to your defined server, which is an AS/400 server in our case. 4. Once you have published your Web pages, make sure your WebSphere Application Server and Web server are both started. 5. To test retrieving all items from the shopping cart, select the cartselectinput.html file. Then, right-click, and select Preview file with Netscape or Internet Explorer. 6. When the Web browser appears fill out the form, then click the Submit button. The form appears as shown in Figure 280. Figure 280. Unit testing SELECT from SHPCART table Modifying the resulting page of the shopping cart selection In this section, we modify cartselectresult.jsp to add input fields for the user to enter information. We also add the form with the Submit and Reset buttons to invoke the servlet, which instantiates another bean and calls the AS/400 server program Modifying the resulting JSP cartselectresult.jsp Perform the following steps to modify the cartselectresult.jsp file: 1. Double-click cartselectresult.jsp to open it for editing in Page Designer. You should see the window as shown in Figure 281 on page 298. ABC Company Web site design and development 297

308 Figure 281. Original look of cartselectresult.jsp 2. Fix the table headings. Highlight the headings and type something a user can read and understand. 3. Add the form (select Insert->Form and Input Fields) with input fields and Submit and Reset buttons. 4. Examine the page in Figure 282 to get the idea of what the page should look like after the modifications. Figure 282. cartselectresult.jsp after modifications 5. Leave the form action blank for now. However, the form method radio button should reflect the Post setting (Figure 283). 298 Web Enabling AS/400 Applications with IBM WebSphere Studio

309 Figure 283. Form attributes on cartselectresult.jsp Note: Credit card information input fields are on the page for illustration purposes only. It is generally accepted to collect this kind of information in e-commerce applications. In our scenario, this user entered information that was not taken into consideration. We added the form with the Submit button to have the means to invoke (call) the servlet, which will: Instantiate a bean with shopping cart data. Upon successful retrieval of the shopping cart contents, format, package, and submit the order onto the AS/400 server for further processing. In the next section, we create the servlet, the bean, and the resulting pages Creating the servlet, DB access bean, and JSPs to submit the order In this section, we create the servlet and the DB access bean to get the result of the shopping cart select query, which should return the shopping cart contents found for the particular customer. We then retrieve the data from the bean to format and package the order to be sent as parameters for the call to the AS/400 RPG program. We need to create another bean to hold shopping cart contents, since we cannot use cartselectdbbean, because we need more information in the new bean. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderPurchase. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. ABC Company Web site design and development 299

310 4. Select the appropriate SQL statement, which you created in 7.5.2, Creating SELECT SQL for the SHPCART table on page 293. It should be drive:\subsites\orderpurchase\selectcart.sql. 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information in Table 36. Table 36. Information to be entered in the Database Wizard Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The input page does not require any parameters. Click Next. Results Page Make sure all the fields (columns) from the shopping cart table (SHPCART) are selected. Select the parameters by clicking on the row. Click the Change button to change the captions to a more meaningful names. You can also change the field sizes. Repeat this for all the parameters. Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session There is really no need to store this bean in the session. This bean will be used just to display shopping cart contents and collect other information from the user. Make sure No is selected. Name the bean sbmorderdbbean. Click Next. 300 Web Enabling AS/400 Applications with IBM WebSphere Studio

311 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button and type sbmorder into the Prefix dialog. Click OK. Note that all of the files now have the prefix of sbmordert. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 7. Check all of the generated files (all files having the sbmorder prefix) into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option. 8. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page Unit test is optional since this bean is similar to cartselectdbbean. However, you may still verify your work. 10.To test the order purchase submit, select the sbmorderinput.html file. Then, right-click, and select Preview file with Netscape or Internet Explorer. 11.Enter a customer ID, which has entries in the shopping cart table. Then, click Submit. Upon successful execution, you should see the shopping cart order contents Developing Java code to package and submit the order to the AS/400 server In this section, we develop Java code to retrieve shopping cart data from the sbmorderdbbean, format the data appropriately, package it into two parameters, and finally call the AS/400 server program to take over with the order creation process. We show different ways of calling the AS/400 server program using the AS/400 ToolBox for Java. We also explain where to insert the Java code and why. The functional flow is presented here: 1. The sbmorder servlet is invoked by the Post method from the form inside the sbmorderinput.html, with cust as a parameter representing cust ID. Later it will be called from the cartselectresults.jsp. Refer to , Creating a self-contained order purchase subsite on page 336, for an explanation on how cartselectresult.jsp calls the sbmorder servlet with the cust ID parameter. 2. The sbmorder servlet instantiates sbmorderdbbean. At this stage, the servlet also executes the bean s setter methods. ABC Company Web site design and development 301

312 3. The sbmorder servlet calls the execute() method of sbmorderdbbean, which runs the SQL statement and loads the bean s properties with the shopping cart data. 4. We insert our order retrieval code (retrieval from the bean) right after the execute() method. We later explain why precisely after the execute() method 5. We insert the following methods inside the sbmorder servlet(notinsidethe performtask(...) method, where the execute() method is called): The prepare_submit_order() method to package and format order data according to AS/400 server program s parameters specifications The submitorder() method to call the AS/400 server program and pass parameters Inside the sbmorder servlet, bean instantiation and the execute() method occur inside the Java language try { } block, which is followed by the catch { } block, all inside the performtask(...) method. Refer to the code extract shown in Figure 284. If we are to insert the code inside the servlet to access the sbmorderdbbean bean s properties and methods, we need to do it inside the try{}block. Otherwise, any reference to the bean s properties and methods is out of the scope of this redbook. The Java compiler produces a Can t make static reference to... error message if an attempt is made to call a bean s method. Our strategy is to insert order processing code, which requires access to the bean s methods, inside the try{}block, and the rest of the code (prepare_submit_order() and submitorder() methods) can be inserted anywhere outside of performtask(...) method. There will be a couple of exceptions, which we will explain in detail. 302 Web Enabling AS/400 Applications with IBM WebSphere Studio

313 /***************************************************************************** * Process incoming requests for information * request Object that encapsulates the request to the servlet response Object that encapsulates the response from the servlet */ public void performtask(httpservletrequest request, HttpServletResponse response) { try { // instantiate the beans and store them so they can be accessed by the called page OrderPurchase.sbmorderDBBean sbmorderdbbean = null; sbmorderdbbean = (OrderPurchase.sbmorderDBBean) java.beans.beans.instantiate(getclass().getclassloader(), "OrderPurchase.sbmorderDBBean"); setrequestattribute("sbmorderdbbean", sbmorderdbbean, request); // Initialize the bean userid property from the parameters sbmorderdbbean.setuserid(getparameter(request, "userid", true, true, false, null)); // Initialize the bean password property from the parameters sbmorderdbbean.setpassword(getparameter(request, "password", true, true, false, null)); // Initialize the bean URL property from the parameters sbmorderdbbean.seturl(getparameter(request, "URL", true, true, false, null)); // Initialize the bean driver property from the parameters sbmorderdbbean.setdriver(getparameter(request, "driver", true, true, false, null)); // Initialize the bean cust property from the parameters sbmorderdbbean.setcust(getparameter(request, "cust", true, true, true, null)); // Call the execute action on the bean. sbmorderdbbean.execute(); // Call the output page. If the output page is not passed // as part of the URL, the default page is called. callpage(getpagenamefromrequest(request), request, response); } // handle com.ibm.webtools.runtime.nodataexception catch (com.ibm.webtools.runtime.nodataexception theexception) { try { callpagenamed(getparameter(request, "com.ibm.webtools.runtime.nodataexception", true, true, false, "com.ibm.webtools.runtime.nodataexception"), request, response); } catch (Throwable e) { handleerror(request, response, theexception); } } } catch (Throwable theexception) { handleerror(request, response, theexception); } Figure 284. The performtask() method inside the sbmorder servlet ABC Company Web site design and development 303

314 You should note that the final code produced may not be the most elegant and stylish. However, we heavily use the Studio Wizards, which tremendously reduce the amount of code to be written, yet provide most of the functionality required. We could have inserted the code straight into the bean. However, it would then seize being just a bean, since database access beans are only designed to retrieve the data and provide access to the data via the getters Retrieving the order data from the bean It is quite easy and straight forward to get the order data from the bean. Calling the appropriate getter methods achieves the goal. We need to format and package the order data to be passed in the form of parameters to the AS/400 server program. We could have only formatted and packaged the order data to comply with parameters specifications of the called AS/400 program, but we took it one step further. The model we preferred is optional, but it can be extremely useful. Before the order data gets formatted and packaged for submission (the call to the AS/400 server program), we construct Order and OrderDetail objects. The benefit is: To demonstrate how to import files into WebSphere Studio and make the classes not generated by the Studio Wizards work. Have the objects available to build upon in the future. The Order and OrderDetail objects are Order.java and OrderDetail.java classes respectively. The class files contain constructors and methods associated with manipulations on the order data. The Order class is examined here: public class Order { private StringBuffer customerid = new StringBuffer(4); private OrderDetail[] entryarray = new OrderDetail[50]; private int index = -1; private int cursor = 0; } As shown, an Order object contains an array of OrderDetail objects. The size of this array is arbitrarily set to 50. You can also use a vector, which avoids having to determine a size in advance. Vectors allow dynamic allocation, where arrays do not. The customerid field is declared as a StringBuffer, rather than a String. This is because leading zeros may have to be inserted. The AS/400 system program that is eventually called expects a buffer of character data. Certain fields need to have specific lengths, so offsets are predictable. The customerid field must always be a length of 4. If the customerid retrieved from the bean is 10, then two leading zeros must be inserted to yield This is shown in the constructor: public Order ( String cid) { // Set the customer id making sure leading zeros are // included. for(int i=0;i<4-cid.length( );i++) { customerid.append('0') } 304 Web Enabling AS/400 Applications with IBM WebSphere Studio

315 } customerid.append(cid); The OrderDetail class is shown here: public class OrderDetail { StringBuffer itemid = new StringBuffer(6); StringBuffer itemdsc = new StringBuffer(24); BigDecimal itemprice = null; BigDecimal itemqty = null; } As in the Order class, certain data members have a specific length. In this case, itemid and itemdsc are declared as StringBuffer types. In some cases, the constructor must add leading zeros to the itemid. It may also have to add trailing blanks to itemdsc. The constructor, is shown in Figure 285. public OrderDetail( String itemid, String itemdsc, BigDecimal itemprice, BigDecimal itemqty) { // set the itemid making sure leading zeros are there for(int i=0;i<6-itemid.length();i++) { this.itemid.append('0'); } this.itemid.append(itemid); // set the description making sure trailing blanks are there this.itemdsc.append(itemdsc); for(int j=itemdsc.length()+1;j<25;j++) { this.itemdsc.append(' '); } this.itemprice = itemprice; this.itemqty = itemqty; } Figure 285. OrderDetail class constructor Now that you have a fair understanding of the Order and OrderDetail classes, let us examine the code to create and initialize the Order and OrderDetail objects using the bean s data Inserting Order and OrderDetail files into WebSphere Studio Firstofall,weimporttheOrder.java and OrderDetail.java classes into the WebSphere s OrderPurchase project. Follow these steps: 1. Copy the Order.java and the OrderDetail.java files into the \subsites\orderpurchase\servlet\orderpurchase folder using the Windows Explorer or a copy command issued from command prompt. ABC Company Web site design and development 305

316 2. Highlight the OrderPurchase package under the servlet folder inside the Studio Workbench to make sure the Order.java will be inserted there. 3. Inside the Studio Workbench, click Insert->File. 4. Click the Use Existing tab to insert the existing Order.java file, rather than generate one based on a template. 5. Click the Browse button to select the Order.java file, and then click the OK button. The Order.java file should now be visible inside Studio Workbench. Repeat the same steps for the OrderDetail.java file. Make sure, the Order and OrderDetail classes contain the following statement to indicate the package name: package OrderPurchase; Modifying the sbmorder servlet to create and package order objects Perform the following tasks to edit and modify the sbmorder servlet: 1. Open the sbmorder servlet for editing. 2. Specify the import statements to import the Order and OrderDetail classes into the sbmorder servlet. Type the following statements into the sbmorder.java servlet: // Order objects and math package to use for data type conversions import OrderPurchase.Order; import OrderPurchase.OrderDetail; import java.math.*; 3. Insert the code to get the data from sbmorderdbbean to instantiate and initialize the Order and the OrderDetail objects. Immediately after the following lines, in sbmorder.java, enter: // Call the execute action on the bean. sbmorderdbbean.execute(); 4. Insert the code segment shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

317 // Retrieve data from the bean // Get the number of rows retrieved from shopping cart int numentries = sbmorderdbbean.result.getnumrowsincache(); // Instantiate the Order object Order theorder = new Order(sbmorderDBBean.getCust()); // Instantiate the OrderDetail objects and add them to the Order object // The number of iterations in the loop depends on the number of records in the shopping cart for (int i = 0; i < numentries; i++) { OrderDetail detail = new OrderDetail(sbmorderDBBean.getAPILIB_SHPCART_SIID(i).toString(), sbmorderdbbean.getapilib_shpcart_sdsc(i).tostring(), new BigDecimal(sbmorderDBBean.getAPILIB_SHPCART_SPRC(i).toString()), new BigDecimal(sbmorderDBBean.getAPILIB_SHPCART_SQTY(i).toString())); theorder.addentry(detail); } // Prepare and submit an order to the AS/400 to process if (prepare_submit_order(theorder) == true) { } Figure 286. Retrieving order data from the bean to the package and submit order Let us examine the code segment in Figure 286 to retrieve the order data from sbmorderdbbean. First, we find out how many rows are in the result set of the SQL run by sbmorderdbbean. The bean has the following instance variable: /** * Variable for the SelectResult - the SQL result set */ protected SelectResult result; One of the methods in the result object is getnumrowsincache(), which returns the number of rows in the SQL result set as an integer. To call the method, we fully qualify its name: int numentries = sbmorderdbbean.result.getnumrowsincache(); Next, we construct the Order object by passing the cust Id, which we get from the bean via the getter method: // Instantiate the Order object Order theorder = new Order(sbmorderDBBean.getCust()); Then, we construct the OrderDetail objects for every row (detail record) retrieved from the bean. Therefore, we do it inside the loop. To get the data elements from the result set in the bean, we call the getter methods. We take whatever the getter method returns and convert it to the string by running the tostring() method. Since the Order object contains the array of OrderDetail objects, we execute the following line (the method from the Order object), also in the loop: theorder.addentry(detail); Finally, in the inserted code block, we call a method to prepare the parameters and call the AS/400 server program: ABC Company Web site design and development 307

318 // Prepare the order and call AS/400 program prepare_submit_order(theorder); Let us recall the flow up to this point in the code. The sbmorder servlet instantiates the sbmorderdbbean bean and calls the sbmorderdbbean.execute() method, which executes the SQL statement and loads the bean with order data from the shopping cart table (SHPCART) on the AS/400 system. We inserted the code to create the Order and the OrderDetail objects. Next, we call the prepare_submit_order() method and pass the Order object as a parameter. The code in Figure 287 should be inserted after } of the following method: public void performtask(httpservletrequest request, HttpServletResponse response) /* This method builds the constructs that are used as parameters when invoking the AS/400 program that processes orders. One parameter is required by this method, the Order object, which contains the cust Id and order detail data.*/ void prepare_submit_order(order theorder) { String orderstring = theorder.tostring(); StringBuffer headerbuffer = new StringBuffer(9); headerbuffer.append(orderstring.substring(0, 9)); StringBuffer detailbuffer = new StringBuffer(orderString.length() - 9); detailbuffer.append(orderstring.substring(9)); // now invoke submitorder() and pass the 2 parms submitorder(headerbuffer.tostring(), detailbuffer.tostring()); return; } Figure 287. prepare_submit_order method to be inserted into the sbmorder servlet The prepare_submit_order() method builds the constructs that are used as parameters when starting the AS/400 server program, which processes orders (ORDENTR), but in reality we call ORDENTRCL. This program requires two parameters. The first parameter is a string that is a concatenation of the customer ID and the number of entries in the order. This data is fixed in length. The first 4 bytes are designated for the customer ID, while the last 5 bytes are for the number of entries. The ORDENTR program moves the customer ID data into a character field that has a length of 4 bytes. The last 5 bytes are moved to a zoned numeric field. These 9 bytes of data are the first 9 bytes in the string that is returned by Order.toString(). The second parameter is a block of character data that represents all of the detail entries in the order. This data is sent as one contiguous block of character data to the ORDENTR program that parses the data. This block of data is also part of the string that is returned by Order.toString(). It begins at offset 9 of the string. Since the AS/400 server program that processes orders (ORDENTR) expects all character data, a tostring() method is provided in the Order class. This method converts the Order object into one contiguous string. The string may be viewed as a buffer with the following breakdown: 308 Web Enabling AS/400 Applications with IBM WebSphere Studio

319 Starting at offset 0 for a length of 4 bytes: The customer ID Starting at offset 4 for a length of 5 bytes: The number of detail entries Starting at offset 9 with varying length: Multiple 40-byte segments Each 40-byte segment represents a single detail record that consists of an item ID, name, price, and quantity. See the OrderDetail.toString() method for a granular breakdown of a detail record. Figure 288 shows the tostring() method for the Order class. public String tostring() { // declare a StringBuffer StringBuffer orderbuffer = new SringBuffer(9+(40*getNumEntries())); // append the customerid to the buffer orderbuffer.append(customerid); // convert the number of entries to a string of 5 bytes // and be sure to include leading zeros StringBuffer numentrybuffer = new StringBuffer(5); String numentrystring = Integer.toString(getNumEntries( )); for(int i=0;i<5-numentrystring.length( );i++) { numentrybuffer.append('0'); } numentrybuffer.append(numentrystring); // append the number of entries string to the order buffer orderbuffer.append(numentrybuffer); // now append a string representation of all entries to // the buffer OrderDetail entry = getfirstentry(); while(entry!= null) { // append a string representation of the detail entry // this is done by invoking the tostring( ) method that // is provided by the OrderDetail class orderbuffer.append(entry.tostring( )); entry = getnextentry( ); } // return the complete StringBuffer as a String // this is done by invoking the tostring( ) method that is // provided by Java's StringBuffer class return orderbuffer.tostring( ); } Figure 288. The tostring() method of the Order class The OrderDetail class also provides a tostring() method. Once again, this facilitates the call to the AS/400 server program that accepts parameters as character data. The tostring() method converts the orderdetail object to a buffer of 40 characters with certain offsets that are designated as starting points of certain data members. The breakdown of the orderdetail buffer is: Starting at offset 0 for 6 bytes: The item ID Startingatoffset6for24bytes:Theitemname(description) Startingatoffset30for5bytes:Theprice Starting at offset 35 for 5 bytes: The quantity ordered ABC Company Web site design and development 309

320 Figure 289 shows the tostring() method for the OrderDetail class. public String tostring( ) { StringBuffer entrybuffer = new StringBuffer(40); entrybuffer.append(itemid); entrybuffer.append(itemdsc); // convert price field to String, remove // decimal point, and make sure leading // zeros are there StringBuffer pricebuffer = new StringBuffer(5); String pricestring = itemprice.tostring(); // find out the position of the decimal point int decimalposition = pricestring.indexof('.'); // create a new string that contains the digits // before the decimal point String pricestring1= pricestring.substring(0,decimalposition); // create a new string that contains the digits // after the decimal point String pricestring2 = pricestring.substring(decimalposition+1) // now combine the 2 pricestring = pricestring1 + pricestring2; // insert any needed leading zeros for(int i=0;i<5-pricestring.length();i++) { pricebuffer.append('0'); } pricebuffer.append(pricestring); // now append it to the entry buffer entrybuffer.append(pricebuffer); // convert the quantity field to String and make sure // it is 5 bytes StringBuffer qtybuffer = new StringBuffer(5); String qtystring = itemqty.tostring(); for(int i=0;i<5-qtystring.length();i++) { qtybuffer.append('0'); } qtybuffer.append(qtystring); // now append it to the entry buffer entrybuffer.append(qtybuffer); } // now return the whole entry as a String return entrybuffer.tostring(); Figure 289. The tostring() method of the OrderDetail class In the next section, we examine the method that is responsible for calling an AS/400 server program, passing parameters, and some error handling Calling the AS/400 server program to submit the order After setting up the two parameters, prepare_submit_order() calls the submitorder() method. We demonstrate two ways to call the AS/400 server programs: Using the Distributed Program Call (DPC) class provided by the AS/400 Toolbox for Java 310 Web Enabling AS/400 Applications with IBM WebSphere Studio

321 Using PCML classes also provided by the AS/400 Toolbox for Java To use AS/400 Toolbox for Java DPC and PCML classes to call a program on AS/400 server, the following import statements are needed inside the sbmorder servlet: // Creating AS400 object to call AS/400 program import com.ibm.as400.access.*; // PCML Example imports import com.ibm.as400.data.programcalldocument; import com.ibm.as400.data.pcmlexception; Both DPC and PCML methods require the creation of the object of AS/400 type to access the AS/400 server. Creation of the object of the AS/400 type requires the following parameters: system name, user ID and password. Declare the following variables to have the global scope (at the sbmorder.java class level): String pgmcallurl; String pgmcalluserid; String pgmcallpwd; At some point during execution, the variables need to be initialized. We initialize the variables inside the try {} block of the performtask() method right after the call to execute() method. Recall the reason we have to do it inside the try {} block after the execute() method. We do it inside the try {} blocktobeinthe same scope to access the bean s methods and properties. We do it after the execute() method because it loads the bean s properties with data from the database or passed parameters. // Initialize this variables to be used by submitorder() method to create as400 object pgmcallurl = sbmorderdbbean.geturl(); pgmcalluserid = sbmorderdbbean.getuserid(); pgmcallpwd = getparameter(request, "password", true, true, false, null); In the following section, we examine the submitorder() method using DPC Calling the AS/400 server program using the DPC class The submitorder() method calls the ORDENTCL program on the AS/400 system using the Distributed ProgramCall class (DPC). Figure 290 on page 312 shows the code listing and analysis for the submitorder() method to be inserted after the prepareorder() method. First, we do a couple of declarations. We declare and initialize an AS/400 object using system name, user ID and password. We call the object as400system. Recall the global variables from the previous section. We use them to create the as400system object of AS/400 type. Also, in case a call fails, we declare msgid and msgtext to hold the values to output them to standard out. Note When a servlet issues output to stdout, the WebSphere Application Server places the output inside the jvm_stdout.log file located inside application server s logs folder. While troubleshooting or debugging the servlet call, you can issue System.out.println statements to output debugging text. ABC Company Web site design and development 311

322 private boolean submitorder(string header, String detail) { String msgid, msgtext;// Messages returned from AS/400 // Get system name from the URL string (system name starts after "//" characters) String systemname = pgmcallurl.substring(pgmcallurl.lastindexof("/") + 1); AS400 as400system = new AS400(systemName, pgmcalluserid, pgmcallpwd); try { as400system.connectservice(as400.command); ProgramCall ordentrpgm = new ProgramCall(as400System); QSYSObjectPathName pgmname = new QSYSObjectPathName ("APILIB","ORDENTRCL","PGM"); ProgramParameter[] parmlist = new ProgramParameter[2]; // set the first parameter which is the order header AS400Text text1 = new AS400Text(9); byte[] headerinfo = text1.tobytes(header); parmlist[0] = new ProgramParameter(headerInfo); // set the first parameter which is the order header AS400Text text2 = new AS400Text(detail.length()); byte[] detailinfo = text2.tobytes(detail); parmlist[1] = new ProgramParameter(detailInfo); ordentrpgm.setprogram(pgmname.getpath(),parmlist); // if you hang here - the AS/400 server job (QZRCSRVS) // may be waiting on an inquiry message and control // will never return. Check the QZRCSRVS joblog if (ordentrpgm.run()!= true) { // If you get here, the program failed to run. // Get the list of messages to determine why // the program didn't run. AS400Message[] msgs = ordentrpgm.getmessagelist(); // write them to standard output for (int m = 0; m < msgs.length; m++) { msgid = msgs[m].getid(); msgtext = msgs[m].gettext(); System.out.println(" " + msgid + " - " + msgtext); } System.out.println("** Call to ORDENTRCL failed. See messages above **"); return false; } else { System.out.println("Order successfully submitted"); } } catch(exception e) { System.out.println("Error submitting order"); // Uncomment the following lines to print uncaught exceptions to stdout System.out.println(" UNCAUGHT EXCEPTION "); e.printstacktrace(system.out); return false; } return true; } Figure 290. The submitorder() method using DPC to call the AS/400 program The value of the pgmcallurl variable in our case is jdbc:as400://as20. AS20isa system name. 312 Web Enabling AS/400 Applications with IBM WebSphere Studio

323 Then, we start the AS400.COMMAND service for the as400system object. Note The AS/400 Toolbox for Java implicitly starts this if it needs to be started. It is shown here for clarification: as400.connectservice(as400.command); We declare a ProgramCall object called ordentrpgm. Then, we set the name of the AS/400 system program associated with this object by declaring and initializing a QSYSObjectPathName object: ProgramCall ordentrpgm = new ProgramCall(as400System); QSYSObjectPathName pgmname = new QSYSObjectPathName("APILIB","ORDENTRCL","PGM"); Once this is done, you must set the parameters for this program. To set the parameters, perform these steps: 1. Declare an array of ProgramParameter objects. We declare an array of two, since the program requires two parameters, by entering: ProgramParameter[] parmlist = new ProgramParameter[2]; 2. Construct the individual ProgramParameter elements to fill the array. The ProgramParameter constructor must be passed an array of bytes. Before instantiating a ProgramParameter object, we must first generate the appropriate array of bytes. To create the array of bytes, follow these steps: a. Declare an appropriate AS/400 system data type object. In this case, we are passing string data, so we declare an AS400Text object. b. Start the tobytes() method on this AS400Text object and pass the string that is being converted to bytes. Here are the two steps that you need: AS400Text text1 = new AS400Text(9); byte[] headerbytes = text1.tobytes(header); 3. Start the constructor for the ProgramParameter class by entering: parmlist[0] = new ProgramParameter(headerBytes); Now, the same scenario is followed for each additional parameter that you need. Once the parameters have been instantiated, the ProgramCall object must be initialized with the actual name of the AS/400 program that is being called. The parameter list must also be specified by starting the setprogram() method: ordentrpgm.setprogram(pgmname.getpath(),parmlist); We are now ready to run the program. The run() method starts the program. In this example, it is done inside an "if" construct, so any errors may be processed and the return value for the submitorder() method determined: if (ordentrpgm.run()!= true) { If the code gets here (inside the if construct), the program failed to run. We then get the list of messages to determine why. It all happens inside the if construct. AS400Message[] msgs = ordentrpgm.getmessagelist(); // write them to standard output ABC Company Web site design and development 313

324 for (int m = 0; m < msgs.length; m++) { msgid = msgs[m].getid(); msgtext = msgs[m].gettext(); System.out.println(" " + msgid + " - " + msgtext); } System.out.println("** Call to ORDENTRCL failed. See messages above **"); return false; } We left the code to output the messages to stdout uncommented for illustration purposes. One important fact should be noted here. If the program on the AS/400 system issues a message that waits for a response (an inquiry message), then control is never returned. The submitorder() method hangs on the ordentrpgm.run() method. If this occurs, you must check the server job that is handling the request on the host AS/400 system. This job has a name of QZRCSRVS, and its job log should be viewed. If the program runs successfully, the submitorder() method returns a true boolean value. If the submitorder() method returns a true boolean value, prepare_submit_order() method returns a true boolean value. That is how we know whether the order is submitted successfully, and we could empty the shopping cart and produce appropriate confirmation page for the user Calling the AS/400 server program using PCML classes Program Call Markup Language (PCML) is an alternative way to call AS/400 programs. It allows you to define an interface using PCML, which is another extension to XML. PCML simplifies calling AS/400 objects since it performs operations such as the parameter conversions that are required when using a ProgramCall method. XML extensible Markup Language (XML) is a tag-based language based on Standard Generalized Markup Language (SGML). SGML is a document language intended for creating large complex documents. XML provides a format for describing data and information. It presents an application with data and describes what the data represents at the same time. Many industries, noticeably publishing and scientific research, are finding that XML provides them a solution to the age-old problem of describing data in an application-neutral format. XML looks similar to HTML in the sense that they are both tag-based languages. However, HTML is more concerned about how to lay out information to present it to a user rather than the meaning of the data. XML provides the possibility of attaching style information to an XML data file so that it can be rendered in a desired fashion. Its primary concern is data, not display. The real power of XML is the ability to create tags that have meaning to each particular application. It allows the separation of the data from the presentation of the data, so the data can remain intelligent. The AS/400 Toolbox for Java provides two implementations using XML, which are: Panel Definition Markup Language (PDML) Program Call Markup Language (PCML) 314 Web Enabling AS/400 Applications with IBM WebSphere Studio

325 PCML is a way to describe program call interfaces. The Java to AS/400 implementation for PCML automatically converts data between AS/400 data types and Java Object classes (such as Integer, String, Float, and so on). In addition, you only need to define the program interface in a single PCML file. This encourages reuse and makes maintaining the interface between legacy programs and Java easier. PCML PCML enables you to define tags that fully describe AS/400 programs that will be called by your Java application. PCML was created to simplify calling AS/400 programs from Java. It performs the following functions: It converts data types between the AS/400 format and the Java format. It simplifies Java programs by handling complex relationships in AS/400 data: Varying length character strings and structures Varying size arrays of fields and structures and nested arrays Strings with runtime CCSID tagging PCML is implemented as a package of Java classes: com.ibm.as400.data(data400.jar) Figure 291 shows how PCML works. Figure 291. PCML architecture To build AS/400 program calls with PCML, you must start by creating: A Java application (can be a application, servlet, or bean) A PCML source file Depending on your application design, you must write one or more PCML source files where you describe the interfaces to the AS/400 programs that will be called ABC Company Web site design and development 315

326 by your Java application. When your application constructs a ProgramCallDocument object, the IBM XML parser reads and parses the PCML source file. After the ProgramCallDocument class is created, the application program uses the ProgramCallDocument class methods to retrieve the necessary information from the AS/400 system through the AS/400 distributed program call (DPC) server. To increase runtime performance, the ProgramCallDocument class can be serialized. The ProgramCallDocument class is then constructed using the serialized file. In this case, the IBM XML parser is not used at runtime. PCML file PCML consists of the following tags, each of which has its own attribute tags: Program tag: Begins and ends code that describes one program. Struct tag: Defines a named structure, which can be specified as an argument to a program or as a field within another named structure. A struct tag contains a data or a struct tag for each field in the structure. Data tag: Defines a field within a program or structure. Figure 292 shows the PcmlPgmCall PCML file, which is used when we call the ORDENTRCL program from sbmorder servlet. The Java application uses PCML by constructing a ProgramCallDocument object with a reference to the PCML source file. The ProgramCallDocument considers the PCML source file to be a Java resource. Consequently, the PCML source file is found using the Java CLASSPATH. We import the PcmlPgmCall.pcml file into WebSphere s OrderPurchase project. Follow these steps: 1. Copy the PcmlPgmCall.pcml file (can be created using any text editor) into the \subsites\orderpurchase\servlet\orderpurchase folder using Windows Explorer or a copy command issued from command prompt. 2. Highlight the OrderPurchase package under the servlet folder inside the Studio Workbench to make sure PcmlPgmCall.pcml will be inserted there. 3. Inside the Studio Workbench, click Insert->File. 4. Click the Use Existing tab to insert the existing PcmlPgmCall.pcml file rather than generate one based on a template. 5. Click the Browse button to select the PcmlPgmCall.pcml file. Then, click the OK button. The PcmlPgmCall.pcml file should now be visible inside the Studio Workbench. Make the file publishable (Figure 292). 316 Web Enabling AS/400 Applications with IBM WebSphere Studio

327 <pcml version="1.0"> <!-- PCML source for calling "ORDENTRCL" Program --> <!-- Program PgmCall and its parameter list for retrieving part records --> <program name="pcmlpgmcall" path="/qsys.lib/apilib.lib/ordentrcl.pgm"> <data name="asheader" type="char" length="9" usage="inputoutput" init=" "/> <data name="asdetail" type="char" length="2000" usage="inputoutput" init=" "/> </program> </pcml> Figure 292. PCML source file PcmlPgmCall.pcml The name of the AS/400 program that we call is named ORDENTRCL. It is found in the library named APILIB. ORDENTRCL accepts two parameters. To send information to the AS/400 program, we set two input/output parameters: asheader asdetail Notice that we specify the usage as input/output for all the parameters. This is in case we change the AS/400 program to put something back inside the parameters for the servlet to evaluate (confirmation message for example). If we enhance the sbmorder.java servlet to interpret parameters, we can use the same PCML file. How does it all work? We create a ProgramCallDocument object by passing it an AS/400 object and the name of the PCML source file. When an application constructs a ProgramCallDocument object, the IBM XML parser reads and parses the PCML source file. We use the setvalue() method of the ProgramCallDocument object to set the values for the parameters. We use the callprogram() method to actually call the AS/400 program. When the call to the AS/400 program is complete, we use the getvalue() method to retrieve the values of the parameters returned. Notice that we did not have to handle any data conversions. Examining the submitorder() method with PCML objects Figure 293 on page 318 shows the listing of the submitorder() method inside the sbmorder servlet. Some declarations are the same as with using DPC. In case a call fails, we need msgid and msgtext to hold the values to output them to standard out. Note When a servlet issues output to stdout, the WebSphere Application Server places the output inside the jvm_stdout.log file located inside the application server logs folder. While troubleshooting or debugging the servlet call, you can issue System.out.println statements to output debugging text. ABC Company Web site design and development 317

328 private boolean submitorder(string header, String detail) { // Get system name from the URL string (system name starts after "//" characters) String systemname = pgmcallurl.substring(pgmcallurl.lastindexof("/") + 1); AS400 as400system = new AS400(systemName, pgmcalluserid, pgmcallpwd); ProgramCallDocument pcml;// com.ibm.as400.data.programcalldocument boolean rc = false; // Return code from ProgramCallDocument.callProgram() String msgid, msgtext;// Messages returned from AS/400 // Object value; // Return value from ProgramCallDocument.getValue() System.setErr(System.out); try { // Uncomment the following to get debugging information // com.ibm.as400.data.pcmlmessagelog.settraceenabled(true); // When running from VisualAge uncomment System.out.println... to see stdout System.out.println("Beginning PCML Example.."); System.out.println(" Constructing ProgramCallDocument for ORDENTRCL API..."); // Construct ProgramCallDocument // First parameter is system to connect to // Second parameter is pcml resource name. In this example, // serialized PCML file "PcmlPgmCall.pcml.ser" or // PCML source file "PcmlPgmCall.pcml" must be found in the classpath. pcml = new ProgramCallDocument(as400System, "OrderPurchase.PcmlPgmCall"); // pcml.serialize();// uncomment to serialize // Set input parameters. Several parameters have default values // specified in the PCML source. Do not need to set them using Java code. System.out.println(" Setting input parameters..."); // Request to call the API System.out.println(" Calling ORDENTRCL API requesting information for the sign-on user."); pcml.setvalue("pcmlpgmcall.asheader", header); pcml.setvalue("pcmlpgmcall.asdetail", detail); rc = pcml.callprogram("pcmlpgmcall"); // If return code is false, we received messages from the AS/400 if (rc == false) { // Retrieve list of AS/400 messages System.out.println("error occurred"); AS400Message[] msgs = pcml.getmessagelist("pcmlpgmcall"); // write them to standard output for (int m = 0; m < msgs.length; m++) { msgid = msgs[m].getid(); msgtext = msgs[m].gettext(); System.out.println(" " + msgid + " - " + msgtext); } } } System.out.println("** Call to ORDENTRCL failed. See messages above **"); // System.exit(0); return false; Figure 293. submitorder() method with PCML (Part 1 of 2) 318 Web Enabling AS/400 Applications with IBM WebSphere Studio

329 // Write some of the results to standard output catch (PcmlException e) { System.out.println(e.getLocalizedMessage()); e.printstacktrace(); System.out.println("*** Call to ORDENTRCL failed. ***"); return false; } return true; } Figure 294. submitorder() method with PCML (Part 2 of 2) We also need to declare and initialize an AS/400 object using the system name, user ID and password. We called it as400system. Recall the global variables from the previous sections. We use them to create the as400system object of AS400 type. The following Java code constructs as400system and ProgramCallDocument objects: AS400 as400system = new AS400(systemName, pgmcalluserid, pgmcallpwd); ProgramCallDocument pcml; Inside the try {} block, we instantiate a PCML object: pcml = new ProgramCallDocument(as400System, "OrderPurchase.PcmlPgmCall"); The ProgramCallDocument object looks for the PCML source in a file called PcmlPgmCall.pcml. Notice that the.pcml extension is not specified on the constructor. We also need to package qualify the name of the PCML resource. The PCML source file PcmlPgmCall.pcml must be found in the class path, and it is since it is inside the servlet directory under the WebSphere Application Server directories. Next, we set the parameters required by the called application program: pcml.setvalue("pcmlpgmcall.asheader", header); pcml.setvalue("pcmlpgmcall.asdetail", detail); Now, we call the program by running the following statement: rc = pcml.callprogram("pcmlpgmcall"); The actual program name is stored inside the PcmlPgmCall.pcml file. We then evaluate the value of the return code variable rc. Intheif construct, we perform some error handling and error messages output to stdout. Depending on the rc code, the submitorder() method returns true or false. The last two paragraphs of , Calling the AS/400 server program using the DPC class on page 311, apply to the PCML submitorder() method as well. PCML conclusion Calling AS/400 programs from Java applications can require a large amount of programming effort. Ordinarily, you have to write additional lines of code to construct AS/400 Toolbox for Java class objects for connecting to and retrieving information from an AS/400 program and for performing the appropriate data translation. ABC Company Web site design and development 319

330 Using PCML, calls to AS/400 program are handled by PCML class objects. The PCML class objects are generated from PCML tags, which is the PCML coded description of AS/400 programs calls. This minimizes the amount of code you need to write in order to call AS/400 programs from your application. PCML provides a powerful way to call existing AS/400 programs. It can run in any JVM that has the AS/400 Toolbox for Java Modification 2 and the PCML and XML parser archives available. You can write one PCML definition to use in all your Java programs. This allows you to reuse it and makes it easier to maintain. It can also serialize the PCML file for improved runtime performance. To serialize a PCML file, use the ProgramCallDocument class with the -serialize option: Java com.ibm.programcalldocument -serialize pcmlfile The system uses the serialized file if it exists. Also, the IBM XML parser packages are not required at runtime. While PCML was designed to support distributed program calls to AS/400 program objects from a Java client platform, you can also use PCML to make calls to an AS/400 program from within an AS/400 environment. Summary We include both methods inside the sbmorder servlet. One of them will be commented out. Do not forget to compile Order.java and OrderDetail.java prior to compiling sbmorder.java. Also, set the *.pcml file to be eligible for publishing. It may be a good idea to stop and test the order creation process before developing an order confirmation function, which described in the next section Order confirmation: Creating SELECT SQL for the ORDERS table In this section, we are going to create the SELECT statement for the ORDERS table using the SQL Wizard to retrieve a newly created order number, date, and time to be displayed on the confirmation page. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderPurchase. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information in Table 37. Table 37. Information to be entered in the SQL Wizard Tabbed window Action explanation Welcome Enter lastorder as the name of the query. The wizard adds an.sql file in your project. Click Next. 320 Web Enabling AS/400 Applications with IBM WebSphere Studio

331 Tabbed window Logon Action explanation Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button and the wizard connects you to the specified database. Click the Next button to go to the next tab. Tables If the Schema(s) to View window does not appear, click on the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB In this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select APILIB.ORDERS from the list of tables shown. Click Next. Join No action is required. Click Next. Columns Select only the OID, OENTDT, and OENTTM columns to be included in the output result. Click the Add button. Click Next. Condition 1 Specify OCID to be equal to the cust parameter. Note: The cust parameter will be passed to the servlet. Click Next. Sort No action is required. Click Next. ABC Company Web site design and development 321

332 Tabbed window Action explanation SQL No action is required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. Also you can test the SQL statement by pressing the Run SQL button. Click Next. Finish Click Finish. The completed SQL file should appear in the project as lastorder.sql. 5. Check the generated file lastorder.sql into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option Creating servlet and DB access bean for the ORDERS select query In this section, we create the servlet and the DB access bean to get the result of ORDERS select query, which should return the last order record created for the particular customer. However, the SQL we created in the previous section does not return only the last order record. In fact, it returns all the orders. We have the ability to modify the SQL statement that the bean will use to get the data from the database on AS/400 server. We discuss this in detail later in this section. Perform the following tasks that run the Database Wizard to create the HTML form, the servlet, the bean, and resulting JSPs to select all records from the ITEM database table: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderPurchase. 3. Start the SQL Wizard by selecting Tools ->Wizards ->Database Wizard. 4. Select the appropriate SQL Statement, which you created in 7.5.8, Order confirmation: Creating SELECT SQL for the ORDERS table on page 320. It should be drive:\subsites\orderpurchase\lastorder.sql. 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table Web Enabling AS/400 Applications with IBM WebSphere Studio

333 Table 38. Information to be entered in the Database Wizard Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The input page does not require any parameters. Click Next. Results Page The results page already has the output parameters you wanted from the SQL file. These should be OID, OENTDT, and OENTTM. Select the parameters by clicking on the row, and click the Change button to change the caption to a more meaningful name. You can also change the field sizes. Repeat this for the following parameters: For OID, typeorder ID For OENTDT, type Order Date ForOENTTM,typeOrder Time Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean lastorderdbbean. Click Next. ABC Company Web site design and development 323

334 Finish Tabbed window Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type lastorder into the Prefix dialog. Click OK. Note that all of the files now have the prefix of lastorder. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 7. Check all of the generated files (all files having lastorder prefix) into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option. 8. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page 125. Recall that the lastorderdbbean executes the SQL statement to get all the order records for the particular customer. Let us change the SQL statement inside the bean to retrieve only the last order. Here is the original commented out SQL statement followed by the new one: /** * Instance variable for SQL statement property */ // protected java.lang.string SQLString = "SELECT APILIB.ORDERS.OID, APILIB.ORDERS.OENTDT, APILIB.ORDERS.OENTTM FROM APILIB.ORDERS WHERE ( ( APILIB.ORDERS.OCID =? ) ) ORDER BY APILIB.ORDERS.OID DESC"; protected java.lang.string SQLString = "SELECT APILIB.ORDERS.OID, APILIB.ORDERS.OENTDT, APILIB.ORDERS.OENTTM FROM APILIB.ORDERS WHERE ( ( APILIB.ORDERS.OCID =? ) AND (APILIB.ORDERS.OID IN (SELECT MAX(APILIB.ORDERS.OID) FROM APILIB.ORDERS WHERE (APILIB.ORDERS.OCID =? )) ))"; In plain text, first, we find the last order ID created for the particular customer. Then, we select the necessary columns from the ORDERS table based on the customer ID and the last order ID returned in the subquery. As a result of our changes, the SQL statement needs two parameters instead of one (notice the? (question marks) inside the SQL statement). Find the following lines inside the initialize() method: // Create placeholders for the parameters metadata.addparameter("cust", String.class, 1); Add the following line right after the previous lines: metadata.addparameter("cust2", String.class, 1); 324 Web Enabling AS/400 Applications with IBM WebSphere Studio

335 Find the following lines inside the execute() method: // Initialize the parameters for the query sqlstatement.setparameter("cust", getcust()); Add the following line right after the previous lines: sqlstatement.setparameter("cust2", getcust()); Save, check in, and compile the bean to test the last order record retrieval. Unit testing the last order record retrieval To perform the unit test, make sure ORDERS table is not empty. Refer to 7.5.2, Creating SELECT SQL for the SHPCART table on page 293, through 7.5.6, Developing Java code to package and submit the order to the AS/400 server on page 301, for information on placing orders. Perform the following steps to test retrieving the last order information: 1. Select the lastorderinput.html file. Then, right-click, and select Preview file with Netscape or Internet Explorer. When the Web browser appears, the page appears as shown in Figure 295. Figure 295. Last Order record retrieval test: Input form 2. Complete the form, and click the Submit button. The result page should appear as shown in Figure 296 on page 326. ABC Company Web site design and development 325

336 Figure 296. Last Order record retrieval test: Resulting JSP If the call to AS/400 server application program was successful, meaning the order records are created, and we can produce a confirmation page, then we have no use for the shopping cart records. The next two sections deal with emptying the shopping cart Creating the DELETE SQL for the SHPCART table In this section, we create the DELETE SQL statement to delete records from the SHPCART database table using the SQL Wizard. Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderPurchase. 3. Start the SQL Wizard by selecting Tools ->Wizards ->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 39. Table 39. Information to be entered in the SQL Wizard Tabbed window Action explanation Welcome Enter deletecart as the name of the query. The wizard adds an.sql file in your project. Click Next. 326 Web Enabling AS/400 Applications with IBM WebSphere Studio

337 Logon Tabbed window Action explanation Enter the information the wizard needs to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Delete radio button in the Statement type. Select APILIB.SHPCART from the list of tables shown. Click Next. Condition Specify SCID to be equal to cust parameter. Click Next. SQL No action is required. This tab shows the complete SQL statement. You can copy the statement to the clipboard to use it in another application. You can also test the SQL statement by clickinging the Run SQL button. Click Next. Finish Click Finish. The completed SQL file should appear in the project as deletecart.sql. 5. Check the generated file deletecart.sql into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option. ABC Company Web site design and development 327

338 Creating the servlet and DB access bean for the SHPCART delete In this section, we create the servlet and the DB access bean to delete records from the SHPCART table. Perform the following tasks to create the servlet, the bean, and the resulting JSPs: 1. Start WebSphere Studio if not already started. 2. Select the project folder OrderPurchase. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL statement that you created in Section 7.5.8, Order confirmation: Creating SELECT SQL for the ORDERS table on page 320. It should be drive:\subsites\orderpurchase\deletecart.sql. 5. Click Next. 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 40. Table 40. Information to be entered in the Database Wizard Tabbed window Action explanation Web Pages This tab allows you to specify the HTML and JSP files will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the result page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page The input page does not require any parameters. Click Next. Result Page The result page does not require any parameters. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean deleteorderdbbean. Click Next. 328 Web Enabling AS/400 Applications with IBM WebSphere Studio

339 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type lastorder into the Prefix dialog. Click OK. Note that all of the files now have the prefix of lastorder. Click Finish to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 7. Check all of the generated files (all files having deleteorder prefix) into the Studio Workbench. Select the OrderPurchase folder. Then, right-click, and select the Check In option. 8. Publish the project to the AS/400 server. Follow the same steps outlined in 4.3.1, Publishing to the AS/400 system on page 125. You may test the SHPCART records deletion, or you can delay the test until we tie it all together. In the next section, we finally put together the shopping cart retrieval, order placement, confirmation, and shopping cart deletion Order packaging and submission: Tying it all together So far, for the order packaging and submission functionality, we developed standalone functions. The time has come to tie these separate functions together to have functional flow. In this section we modify the sbmorder servlet, and sbmorderresult and sbmordererror JSPs. In 7.5.6, Developing Java code to package and submit the order to the AS/400 server on page 301, we inserted the code into the sbmorder servlet to: Retrieve the order data from the sbmorderdbbean bean Package the order data into two parameters Call the AS/400 server application program Recall that the prepare_submit_order() method, called inside sbmorder servlet, calls the submitorder() method. Both methods return a boolean value. If the AS/400 server program (ORDENTRCL) is called successfully, the submitorder() method returns true. Consequently, the prepare_submit_order() method returns true as well. The return value of the prepare_submit_order() method always equals the return value of the submitorder() method. If the call to AS/400 server application program is successful, then the order is created. This allows instantiation of the bean to retrieve the last order record created to be displayed for the user in the form of confirmation. ABC Company Web site design and development 329

340 Tying together the order submission and order confirmation In 7.5.8, Order confirmation: Creating SELECT SQL for the ORDERS table on page 320, and 7.5.9, Creating servlet and DB access bean for the ORDERS select query on page 322, we created the servlet, bean, and JSPs to retrieve and display the last order record created for a particular customer. Let us insert lastorderdbbean instantiation code inside the sbmorder servlet and merge the lastorderresult JSP into the sbmorderresult JSP. Before inserting the lastorderdbbean instantiation code into the sbmorder servlet, insert the following import statement into sbmorder.java: import OrderPurchase.lastorderDBBean; Open sbmorder.java for editing and lastorder.java for read only. We copy and paste the lastorderdbbean instantiation code into the sbmorder.java. Copy the lines of code shown in Figure 297 from lastorder.java. // instantiate the beans and store them so they can be accessed by the called page OrderPurchase.lastorderDBBean lastorderdbbean = null; lastorderdbbean = (OrderPurchase.lastorderDBBean) java.beans.beans.instantiate(getclass().getclassloader(), "OrderPurchase.lastorderDBBean"); setrequestattribute("lastorderdbbean", lastorderdbbean, request); // Initialize the bean userid property from the parameters lastorderdbbean.setuserid(getparameter(request, "userid", true, true, false, null)); // Initialize the bean password property from the parameters lastorderdbbean.setpassword(getparameter(request, "password", true, true, false, null)); // Initialize the bean URL property from the parameters lastorderdbbean.seturl(getparameter(request, "URL", true, true, false, null)); // Initialize the bean driver property from the parameters lastorderdbbean.setdriver(getparameter(request, "driver", true, true, false, null)); // Initialize the bean cust property from the parameters lastorderdbbean.setcust(getparameter(request, "cust", true, true, true, null)); // Call the execute action on the bean. lastorderdbbean.execute(); Figure 297. lastorderdbbean instantiation code to be inserted into the sbmorder.java servlet Paste the code in Figure 297 inside sbmorder.java after the following lines of code: // Prepare and submit an order to the AS/400 to process if (prepare_submit_order(theorder) == true) { lastorderdbbean will be instantiated only if prepare_submit_order() returns true. Finally, let us merge lastorderresult.jsp into sbmorderresult.jsp to produce a single confirmation page with shopping cart and order number information. 330 Web Enabling AS/400 Applications with IBM WebSphere Studio

341 Open lastorderresult.jsp in Page Designer to select all, and copy and paste into sbmorderresult.jsp. Now, open sbmorderresult.jsp, position the cursor after the last J and select paste. The result is shown in Figure 298. Figure 298. Merging lastorderresult.jsp into sbmorderresult.jsp (Part 1) Enhance the confirmation page look to present it in a more readable form. Remove the customer ID and item ID columns from shopping cart table, and change the table headings. See the Figure 299. Figure 299. Merging lastorderresult.jsp into sbmorderresult.jsp (Part 2) Displaying order total on the confirmation page Anybody who places an order wants to see an order total. Let us describe the method we used to put the order total on the confirmation page. AS/400 database tables ORDERS and ORDLIN do not contain a field holding an order total value. ABC Company Web site design and development 331

342 Consequently, we need to calculate it ourselves. In the process, we modify sbmorderdbbean, the sbmorder servlet, and sbmorderresults.jsp. First, we modify the sbmorderdbbean bean to have the ordertotal property holding order total value. We also include setter and getter methods. Insert the following lines to be together with other bean s instance variables declarations. /** * Instance variable for ordertotal property */ protected java.math.bigdecimal ordertotal; Next, insert the following two methods, getter and setter respectively: /* **************************************************************************** * Get method for the ordertotal property the value of the ordertotal property */ public java.math.bigdecimal getordertotal() { } return ordertotal; /* **************************************************************************** * Set method for the ordertotal property value the new value for the ordertotal property */ public void setordertotal(java.math.bigdecimal value) { } this.ordertotal = value; Save, close, check in, compile, and publish the bean. Let us now modify the sbmorder servlet. Insert the following line of code right before the for loop construct, where we retrieve the order data from the bean, inside the performtaks() method: BigDecimal ordertotal = new BigDecimal(0); This line declares the variable we will increment in the process of retrieving the data from the bean inside the loop. Next, insert the following line of code inside the for loop construct, where we retrieve the order data from the bean, inside the performtaks() method: ordertotal = ordertotal.add( (sbmorderdbbean.getapilib_shpcart_sprc(i).multiply(sbmorderdbbean.getapilib_sh PCART_SQTY(i)) ) ); This line multiplies quantity by price and increments the ordertotal variable. Next, insert the following line of code also inside the sbmorder servlet: sbmorderdbbean.setordertotal(ordertotal); 332 Web Enabling AS/400 Applications with IBM WebSphere Studio

343 inside the if construct, where we test for successful order submission before the following line: callpage(getpagenamefromrequest(request), request, response); The line we inserted sets the bean property with the value we calculated, so it can be later retrieved by the JSP via the getter method. Save, close, check in, compile, and publish the servlet. Lastly, let us modify sbmorderresults.jsp. Open sbmorderresults.jsp in Page Designer. Click Insert->Dynamic Elements->Property Display... to select the sbmorderdbbean s property to be displayed on the page. Refer to the method described in , Creating a final resulting JSP on page 196. In the result, you should see a J symbol representing the ordertotal property (Figure 300). We highlighted the order total line on the figure, so you can see where we placed the J. Figure 300. Adding the order total to sbmorderresults.jsp Tying together order submission and shop cart deletion In , Creating the DELETE SQL for the SHPCART table on page 326, and , Creating the servlet and DB access bean for the SHPCART delete on page 328, we created the servlet, bean, and JSPs to delete the shopping cart contents for a particular customer. Let us insert deletecartdbbean instantiation code inside the sbmorder servlet. Before inserting deletecartdbbean instantiation code into sbmorder servlet, insert the following import statement into sbmorder.java: import OrderPurchase.dltCartDBBean; ABC Company Web site design and development 333

344 Open sbmorder.java for editing and deletecart.java for read only. We copy and paste deletecartdbbean instantiation code into sbmorder.java. Copy the lines of code shown in Figure 301 from deletecart.java. // instantiate the beans and store them so they can be accessed by the called page OrderPurchase.dltCartDBBean dltcartdbbean = null; dltcartdbbean = (OrderPurchase.dltCartDBBean) java.beans.beans.instantiate(getclass().getclassloader(), "OrderPurchase.dltCartDBBean"); setrequestattribute("dltcartdbbean", dltcartdbbean, request); // Initialize the bean userid property from the parameters dltcartdbbean.setuserid(getparameter(request, "userid", true, true, false, null)); // Initialize the bean password property from the parameters dltcartdbbean.setpassword(getparameter(request, "password", true, true, false, null)); // Initialize the bean URL property from the parameters dltcartdbbean.seturl(getparameter(request, "URL", true, true, false, null)); // Initialize the bean driver property from the parameters dltcartdbbean.setdriver(getparameter(request, "driver", true, true, false, null)); // Initialize the bean cust property from the parameters dltcartdbbean.setcust(getparameter(request, "cust", true, true, true, null)); // Call the execute action on the bean. dltcartdbbean.execute(); Figure 301. The dltcartdbbean instantiation code to be inserted into the sbmorder.java servlet Paste the code shown in Figure 301 inside sbmorder.java after the following lines of code: // Prepare and submit an order to the AS/400 to process if (prepare_submit_order(theorder) == true) { Only if prepare_submit_order() returns true, then deletecartdbbean is instantiated (deletes SHPCART table records), and proceeds to lastorderdbbean instantiation Error handling on order submission to the AS/400 server We inserted instantiations of the dltcartdbbean and lastorderdbbean beans inside the if construct (Figure 302). // Prepare and submit an order to the AS/400 to process if (prepare_submit_order(theorder) == true) { } Figure 302. if construct to evaluate successful order submission 334 Web Enabling AS/400 Applications with IBM WebSphere Studio

345 We are not going to delete the shopping cart contents nor retrieve the last order created unless order submission is successful. However, the following line of code (Figure 303), which displays the confirmation page, is executed regardless. // Call the output page. If the output page is not passed // as part of the URL, the default page is called. callpage(getpagenamefromrequest(request), request, response); Figure 303. Displaying the confirmation page in the sbmorder servlet We need to move this line to be the last line inside the if construct, see Figure 302, to ensure the confirmation JSP will be returned only upon successful execution of the order submission. What about if the order submission fails? We specify the else statement clause and to execute the line of code to return error notification page, in this case, No data returned JSP. Refer to Figure 304. else callpagenamed(getparameter(request, "com.ibm.webtools.runtime.nodataexception", true, true, false, "com.ibm.webtools.runtime.nodataexception"), request, response); Figure 304. else clause to return an error notification page If, for some reason, a call to AS/400 application program fails, the user sees the page shown in Figure 305. Figure 305. Order Purchase error page It is important to understand the distinction between system error handling and application error handling. The type of error handling we have in our Web site application protects us from the system failures, for example: The AS/400 system is not accessible. A program object is not accessible. A program object cannot be called for some reason. ABC Company Web site design and development 335

346 However, if the call to the program (ORDENTRCL in our case) is successful, then we are not monitoring for (catching) application errors, such as: A certain file is missing. Certain data elements are missing. Business rules are broken, so order records are not written. To support application error handling, RPG or other types of application programs should return the parameter to the servlet, which called it, so servlet code can evaluate the return parameter to decide if the order submission is successful Creating a self-contained order purchase subsite The objective of this section is to produce a self-contained subsite with one entry point. Let us explain. Let us refer to 7.5.2, Creating SELECT SQL for the SHPCART table on page 293, through 7.5.4, Modifying the resulting page of the shopping cart selection on page 297. We developed a shopping cart retrieval function, which produces intermediate result page, where the users have a chance to review the shopping cart contents and provide credit card information before they actually commit to an order purchase. To start the shopping cart retrieval function (cartselectinput.html), we enter a cust ID parameter to know which shopping cart records to select. This is an entry point into the order purchase subsite. We need this entry point to test the order purchase subsite functionality from the beginning to the end. We also recall 7.5.5, Creating the servlet, DB access bean, and JSPs to submit the order on page 299, through , Creating the servlet and DB access bean for the SHPCART delete on page 328. We developed order packaging and submission functionality to invoke the AS/400 server program to commit the order data to the database. The order packaging and submission function represents the subset of our subsite. It also has an entry point in sbmorderinput.html, where we enter cust ID. In this section, we remove the order packaging and submission entry point, so we have continuous flow from shopping cart retrieval to the order packaging and submission functions. This means, we have to pass the cust ID parameter without having to enter it through sbmorderinput.html. Let us explain one of the ways it can be done. So far, the order purchase subsite contains: Shopping cart retrieval: cartselectinput.html to get the cust Id parameter cartselect servlet to instantiate the cartselectdbbean and produce JSPs resulting JSPs: cartselectresults.jsp, csrtselectnodata.jsp, and cartselecterror.jsp Packaging and submitting order data to the AS/400 server for further processing: sbmorderinput.html to get the cust Id parameter sbmorder servlet to instantiate the sbmorderdbbean, lastorderdbbean, dltcartdbbean beans and produce JSPs 336 Web Enabling AS/400 Applications with IBM WebSphere Studio

347 resulting JSPs: sbmorderresults.jsp, sbmordernodata.jsp, and sbmordererror.jsp We need to modify cartselectresult.jsp, so that when the user clicks the Purchase button, the sbmorder servlet is called and cust Id is passed as a parameter Retrieving form properties from selectcartinput.html Before we start modifying selectcartresults.jsp to invoke order packaging and the submission function, we need to find out which servlet to call and what parameters to pass to that servlet. Since we used the wizards to generate most of the pages, we can easily find the information we need. Follow these steps: 1. Double-click sbmorderinput.html. This checks the file out and opens it in the Page Designer (Figure 306). Figure 306. sbmorderinput.html in Page Designer This page contains information about which servlet to call to invoke order packaging and the submission function and which parameters to pass to that servlet. 2. Double-click inside the input area of the Cust field. You should see the dialog box (Figure 307). Figure 307. sbmorderinput.html name of the customer ID input field ABC Company Web site design and development 337

348 3. Make note of the name of this text field. This text field is called cust. You will need this information later. Click Cancel. Next, we find out which servlet sbmorderinput.html calls. 4. Double-click the Submit button inside sbmorderinput.html. You see the push button attributes dialog box. 5. Click in the drop-down list box next to the Tag caption to select the Form attributes dialog box and see the properties of the form. Refer to Figure 308. Figure 308. Form properties in sbmorderinput.html We need to observe the Action parameter in Figure 308. Make a note of where this action points to, which is /servlet/orderpurchase.sbmorder. This is the location and the name of the servlet, which is called and accepts the parameters as a result of the form submission Modifying selectcartresults.jsp Knowing the servlet name, location, name of the parameter, which is passed to the servlet, we can modify the selectcartresults.jsp page. Follow these steps: 1. Double-click on selectcartresults.jsp. This checks the file out and opens it in the Page Designer (Figure 309). 338 Web Enabling AS/400 Applications with IBM WebSphere Studio

349 Figure 309. Modifying cartselectresults.jsp to call sbmorder servlet (Part 1) 2. Double-click on the Purchase button. You see the push button attributes dialog box. 3. Click in the drop-down list box next to the Tag caption to select the Form attributes dialog box and see the properties of the form. Refer to Figure 310. Figure 310. Form properties in cartselectresults.jsp 4. Type in /servlet/orderpurchase.sbmorder for the Action. Recall that we acquired this information from sbmorderinput.html. 5. Set the method radio button to Post, and click OK. Sofar,theresultingform properties should be as shown in Figure 311 on page 340. ABC Company Web site design and development 339

350 Figure 311. Modifying the cartselectresults.jsp form properties We specified which servlet to call the location of the called servlet. Next, we specify the parameters to pass to the sbmorder servlet. In this case, we have only one parameter, which is cust ID, named cust. One way of passing parameters is using hidden fields on the form. These fields allow us to pass parameters from the form to a servlet without the having the user type anything. Follow these steps: 1. Open the cartselectresults.jsp form Attributes dialog box. 2. Click the Hidden Fields tab inside the dialog box (Figure 312). Figure 312. Adding hidden fields to the cartselectresults.jsp 340 Web Enabling AS/400 Applications with IBM WebSphere Studio

351 Note The hidden fields can still be viewed by the user if they look at the source of the HTML page in the browser. The hidden fields should never contain a user s password or confidential information. In our example, we are not too worried if they find out their customer ID, because they can not do much with it unless they log in successfully. 3. Add one hidden field. The hidden field will represent the customer ID. Click in the Name field, and type cust. This has to be typed exactly the same way as you noted it on the cartselectinput.html page. By setting this parameter, we can have our form call the sbmorder servlet. 4. Recall that cartselectresults.jsp contains cartselectdbbean properties, so the value for the cust parameter will come from cartselectdbbean. Under the Value field, select the check box called Specify by property. Click on Browse to select from bean s properties (Figure 313). Figure 313. Selecting a bean property to supply the parameter value 5. Select the cust bean property to supply the value for the cust parameter. Click OK. 6. In the Attribute dialog, back on the Hidden Fields tab, click the Add button to add this parameter (Figure 314 on page 342). ABC Company Web site design and development 341

352 Figure 314. Adding a parameter as a hidden field to be passed to the servlet 7. Click OK. Save your page, and quit Page Designer. 8. Check in all your files in the WebSphere Studio. 9. Publish only the modified files Order purchase subsite: Final testing In this section, we test all the steps within the order purchase subsite, including: The shopping cart contents display to give the users a chance to review their shopping cart and supply credit card information Shopping cart retrieval to package the order in the subsequent steps Packaging and submitting order data to the AS/400 server for further processing Producing the confirmation page Deleting shopping cart entries if order submission is successful In WebSphere Studio Project Workbench, check in the entire project, and then publish the entire project. Stop and restart the WebSphere Application Server and the HTTP server. Verify that SHPCART table contains records and note the customer ID. Verify that this customer ID exists in the CSTMR table and the redit status fields contains GC (if it does not, the order will not be created). Preview cartselectinput.html, enter the customer ID, click the Submit button. Upon successful execution, the page shown in Figure 315 is displayed. 342 Web Enabling AS/400 Applications with IBM WebSphere Studio

353 Figure 315. Order Purchase: Successful execution Verify the presence of new order records written into the ORDERS and ORDLIN tables. Also, verify that the SHPCART table does not contain records for the customer ID we processed. 7.6 Changes to the Host Order Entry application This section contains details about the transition of the RPG code on the host. The changes are made so the application can run in one of two modes: as a native application with 5250 screen interaction or in conjunction with the newly created Web site, where the application program is called from the servlet. For the most part, the changes are examined in the same sequence as the client application flow Processing the submitted order As previously discussed, the AS/400 system program that handles a request to submit an order is ORDENTR. We had to create the CL program ORDENTRCL to call ORDENTR with the proper library list. Another benefit of calling the ORDENTR program from a CL program is that when an application problem occurs and the error message issued, there are more options available as far as error handling, including the option to restart ORDENTR. When the Order Entry application is run from an AS/400 system 5250 session (no Java client), ORDENTR is the entry point of the application. The ORDENTR program must be changed to separate the presentation and the business logic. ABC Company Web site design and development 343

354 ORDENTR program has to recognize the fact that it was invoked from the servlet and only has to create order records based on passed parameters. First, the number of parameters are ascertained through the program status data structure: D PgmStsDS SDS D NbrParms *PARMS If the number of parameters is greater than zero, it is assumed that the program has been started as a distributed program. Since the Java client passes in two parameters, two data structures are declared that map to the parameters. As discussed earlier, the client passes two strings. The first string is nine characters that represent the customer ID (4 characters) and the number of detail entries (five characters). A data structure named CustDS is declared for this first parameter: D CustDS DS D CustNbr LIKE(CID) D OrdLinCnt 5 0 The second parameter is a string that represents a contiguous grouping of detail entries. Each entry has a length of 40, and there are a maximum of 50 entries. A data structure named OrderMODS is declared for this parameter: D OrderMODS DS OCCURS(50) D PartNbrX LIKE(IID) D PartDscX LIKE(INAME) D PartPriceX 5 2 D PartQtyX 5 0 An entry parameter list is added to the initialization subroutine. This ensures that the data structures are loaded with the parameter values passed in: C *ENTRY PLIST C PARM CustDS C PARM OrderMODS As in other RPG programs, the USROPN keyword is added to the file specification, since the file is not opened when started as a distributed program. Here is the portion of the file specification with the USROPN keyword added:...workstn SFILE(ORDSFL:SflRrn) USROPN The mainline logic of the program is changed to check the number of parameters. If there are parameters, a new subroutine, called CmtOrder2, starts and all display file processing is bypassed: C IF NbrParms > *ZERO C EXSR CmtOrder2 C EXSR EndPgm C ENDIF The CmtOrder2 subroutine is similar to the original CmtOrder subroutine. However, it retrieves the order information from the CustDS and OrderMODS data structures, rather than from the display file and subfile records: CSR CmtOrder2 BEGSR * Web Enabling AS/400 Applications with IBM WebSphere Studio

355 * Get the next order number C EXSR GetOrdNbr * * Get the order date and time C TIME DateTime C Z-ADD *ZERO OrdTot * * Get the customer information C MOVE CustNbr CustomerId C CustKey CHAIN CSRCD * * For each order line in the passed structure... C 1 DO OrdLinCnt OrdCnt C OrdCnt OCCUR OrderMODS * Set up the fields so the existing DB routines work C MOVE PartNbrX PARTNBR_O C MOVE PartDscX PARTDSC_O C MOVE PartQtyX PARTQTY_O C MOVE PartPriceX ITEMPRICE * Add an order detail record... C EXSR AddOrdLin * Update stock record... C StockKey CHAIN STRCD C EXSR UpdStock * Accumulate order total... C EVAL OrdTot = OrdTot + OLAMNT C ENDDO * * Add an order header record... C EXSR AddOrdHdr * * Update customer record... C EXSR UpdCust * * Commit the database changes... C IF CmtActive = $True C COMMIT C ENDIF * * Request batch print server to print order C EXSR WrtDtaQ * CSR ENDSR The subroutine is built, so all other existing subroutines can be used as in the prior version. Once again, the only significant change is that the information for the order is retrieved from the parameters that are passed in Summary The common thread pervasive across all the changes in the host RPG code deals with display file processing. When ORDENTR starts as a distributed program, all display file processing is bypassed. The information normally received from the display files and subfiles is now made available through parameters. Different approaches can be taken. The scenario shown here is not the only valid one. For example, the detail order entries can be passed to the AS/400 system as data queue entries. However, this approach entails more changes in the host application. The amount of change needed at the host end is largely affected by design decisions made for the client side. Keep in mind, to follow a three-tier model, you should have as much business logic on the server as possible and a very thin client running mostly presentation logic. ABC Company Web site design and development 345

356 7.7 Creating the order status subsite To build the order status subsite, we must first create a new project Creating the order status project To build the order status subsite, we need to create a new project. Complete the following steps to create the new Order Status project folder: 1. Start WebSphere Studio if it is not already started. 2. Create a new project by selecting File->New Project. 3. Type OrderStatus for the project name. 4. Type drive:\subsites\orderstatus for the project folder. 5. Select <none> for project template. A new project is created called OrderSatus Building the SQL queries for the order status subsite After a user purchases their products, we want them to be able to see what they have ordered. This section takes you through the process of viewing the order status information. You should already be familiar with the SQL Wizard and the Database Wizard which are discussed in 3.2, Studio Wizards on page Using the SQL Wizard to check customers orders Perform the following tasks that run the SQL Wizard to create an SQL statement that selects order status: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderStatus. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 41. Table 41. Building a select all query for the order status Tabbed window Action explanation Welcome Enter orderstatus as the name of the query. The wizard adds an.sql file in your project. Click Next. 346 Web Enabling AS/400 Applications with IBM WebSphere Studio

357 Tabbed window Logon Action explanation Enter the information the wizard need to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select APILIB.ORDERS from the list of tables shown. Click Next. Join No action is required. Click Next. Columns You need to provide the user with sufficient information so they can identify their order. Select the OCARID, OENTDT, OENTTM, OID, and OLINES elements. Click on the Add button to add them to the columns to include in list box. Click Next. Condition 1 Select OCID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name custid,andclickok. Click Next. ABC Company Web site design and development 347

358 Sort Tabbed window Action explanation You want to display all the orders based on the order date. Click on APILIB.ORDERS.OENTDT.ClicktheAdd buttontoadd it to our columns to sort in the list box. Make sure the sort order is set to Ascending. Click Next. SQL You should now see your SQL statement. To test that it works correctly, click on the Run SQL... button. You are now prompted for one parameter in the Specify Parameter Value(s) window. For the first parameter, type 001 for the custid. Click the OK button. You should see all orders for that customer ID. Click on the Next button, or click the Finish button. Finish Click the Finish button. The completed SQL file should appear in the project as ordrerstatus.sql. 5. Check in the generated file orderstatus.sql to the Studio Workbench. Select the OrderStatus folder. Then, right-click, and select the Check In option Using the SQL Wizard to view order line details Perform the following tasks that run the SQL Wizard to create an SQL statement that selects order line details: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderStatus. 3. Start the SQL Wizard by selecting Tools->Wizards->SQL Wizard. 4. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 42. Table 42. Building a select items in price range query with the catalog Tabbed window Action explanation Welcome Enter orderline as the name of the query. The wizard adds an.sql file in your project. Click Next. 348 Web Enabling AS/400 Applications with IBM WebSphere Studio

359 Tabbed window Logon Action explanation Enter the information the wizard need to connect to the database, for example: Database URL: jdbc:as400://system name Userid: user ID Password: password Driver: AS/400 ToolBox for Java Note: For the database URL parameter, you can supply a host name or the IP address of the AS/400 system. Note: Case is important for the user ID and password; both should be in uppercase. Click the Connect button, and the wizard connects you to the specified database. Click Next. Tables If the Schema(s) to View window does not appear, click the View Schema(s) button. Complete the following steps: In the Schema(s) to View window, find the AS/400 library with which you want to work, which is APILIB in this case. Click on the library to select it, and click the Add button. Click OK to return to the Tables window. Click the Select radio button in the Statement type. Select APILIB.ORDLIN and APILIB.ITEM fromthelistoftables shown. Click Next. Join In the ITEM table, click the IID element, and in the ORDLIN table, click the OLIID element. Both items should be highlighted. Click the Join button. A red line should appear between the two elements. Click Next. Columns Make sure the Selected table(s) list box is set on the ORDLIN element. Select from the Columns list OLAMNT, OLQTY, OLDLVD, andolnbr. Now select ITEM from the Selected table(s) list box. Select INAME and IPRICE from the Columns table. Click Next. Condition 1 Select OLOID in the Columns list box. Select the operator to be is exactly equal to. Click in the top values field, and click the Parameter button. In the Create a new parameter dialog box, enter the variable name orderid, and click the OK button. Click Next. ABC Company Web site design and development 349

360 Tabbed window Action explanation Sort No action is required. Click Next. SQL You should now see your SQL statement. To test that it works correctly, click the Run SQL... button. We are now prompted for one parameter in the Specify Parameter Value(s) window. For this parameter, type 3479 for the orderid. Click the OK button. You should see all order lines for that order ID. Click on the Next button, or just click the Finish button. Finish Click Finish. The completed SQL file should appear in the project as ordrerline.sql. 5. Check the generated file orderline.sql into the Studio Workbench. Select the OrderStatus folder. Then, right-click, and select the Check In option Using the SQL queries in the Database Wizard Now that we have developed our SQL files, we can use them to generate our dynamic JSP pages and servlets. We use the Database Wizard, which was explained in 3.2, Studio Wizards on page Using the Database Wizard on orderstatus.sql Follow these steps: 1. Start WebSphere Studio if it is not already started. 2. Select the project folder OrderStatus. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL statement, which you created in , Using the SQL Wizard to check customers orders on page 346. It should be drive:\subsites\orderstatus\orderstatus.sql. 5. Click Next. 350 Web Enabling AS/400 Applications with IBM WebSphere Studio

361 6. Proceed through the tabbed windows of the wizard, and specify the information described in Table 43. Table 43. Creating dynamic pages from the Database Wizard Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page Make sure the custid check box is selected. This should be done by default since it was the query parameter in the SQL Wizard. Click Next. Results Page The results page will already have the output parameters you wanted from the SQL file. These should be APILIB_ORDERS_OCARID, APILIB_ORDERS_OENTDT, APILIB_ORDERS_OENTTM, APILIB_ORDERS_OLINES, and APILIB_ORDERS_OID. To change the caption displayed in the output file, select OCARID, and click the Change button. A change details dialog box appears. Enter the caption you want to be associated with the OCARID field. Enter the caption Carrier Number. DothesameforOENTDT. Enter Order Date. Now do the same for OENTTM. EnterOrder Time. DothesameforOLINES. Enter Number of items ordered. DothesameforOID. Enter Order ID. Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. Session This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean orderstatusdbbean. Click Next. ABC Company Web site design and development 351

362 Tabbed window Finish Action explanation Give a meaningful name to the generated source files. Click the Rename button, and type orderstatus into the Prefix dialog. Click OK. Note that all of the files now have the prefix of orderstatus. Click the Finish button to generate the code. The Database Wizard generates and compiles the files. The files will be placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 7. You should now see the following files added to the Studio Workbench: orderserror.jsp ordersinput.html ordersnodata.jsp ordersresults.jsp 8. Select the OrderStatus folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you see that the following files are created: orders.class orders.java orders.servlet ordersdbbean.class ordersdbbean.java Using the Database Wizard on orderline.sql Follow these steps: 1. Start WebSphere Studio if not already started. 2. Select the project folder OrderStatus. 3. Start the SQL Wizard by selecting Tools->Wizards->Database Wizard. 4. Select the appropriate SQL Statement, which you created in , Using the SQL Wizard to view order line details on page 348. It should be drive:\subsites\orderstatus\orderline.sql. 5. Click Next. 352 Web Enabling AS/400 Applications with IBM WebSphere Studio

363 6. Proceed through the tabbed windows of the wizard, and specify the information shown in Table 44. Table 44. Creating dynamic pages that require input from the Database Wizard Tabbed window Web Pages Action explanation This tab allows you to specify the HTML and JSP files that will be generated. You need an input page to collect the data for insertion, an output page to show the result from the query, and an error page if something unforeseen happens. You also need to: a. Select the input page check box. b. Select the results page check box. c. Select the error page check box. d. Select the no data is returned check box. Click Next. Input Page Make sure the productid check box is selected. This should be done by default since it was the query parameter in the SQL Wizard. Click Next. Results Page The results page will already have the output parameters you wanted from the SQL file. These should be APILIB_ORDERS_OLAMNT, APILIB_ORDERS_OLQTY, APILIB_ORDERS_OLDLVD, APILIB_ORDERS_OLNBR, APILIB_ITEMS_INAME, and APILIB_ITEMS_IPRICE. To change the caption displayed in the output file, select the OLAMNT. Click the Change button. A change details dialog box appears. Enter the caption you want to be associated with the OLAMNT field. Enter the caption Amount. DothesameforOLQTY. EnterQuantity Ordered. DothesameforOLDLVD. EnterDelivery Date. DothesameforOLNBR. Enter Item number. DothesameforINAME. Enter Product Name. DothesameforIPRICE. EnterProduct Unit Price. Ensure that the Table radio button is selected. Click Next. Standard Error Page No Data Page Methods Click Next. Click Next. Make sure that the method named execute() is selected. Click Next. ABC Company Web site design and development 353

364 Tabbed window Session Action explanation This bean is only to be used one time. We do not need to bind it to the session so make sure No is selected. Name the bean orderlinedbbean. Click Next. Finish Give a meaningful name to the generated source files. Click the Rename button, and type orderline into the Prefix dialog. Click OK. Note that all of the files now have the prefix of orderline. Click the Finish button to generate the code. The Database Wizard generates and compiles the files. The files are placed in a checked out state in the Studio Workbench. You may receive the warning: Issued 1 system warning: *** Warning: "%CLASSPATH%" is either not a valid zip file or it contains a zip file comment. If it contains a comment, rezip it without the comment. You can ignore this warning. 7. You should now see the following files added to the Studio Workbench: orderlineerror.jsp orderlineinput.html orderlinenodata.jsp orderlineresults.jsp 8. Select the OrderStatus folder. Then, right-click, and select the Check In option. If you look inside the servlet directory, you also see that the following files are created: orderline.class orderline.java orderline.servlet orderlinedbbean.class orderlinedbbean.java Testing the Order Status pages Now that the order status pages have been built, we can test then to see if the result is what we want. It is much easier to fix the pages at this point. Make sure you have a publishing target setup. Refer to 4.3.1, Publishing to the AS/400 system on page 125, if you have not done this yet. At this point, it is just for testing. We recommend that you use a directory that has been allocated to you on the AS/400 system. Or, test locally on a Windows NT machine that is running WebSphere Application Server and the Apache Web server. 354 Web Enabling AS/400 Applications with IBM WebSphere Studio

365 Follow these steps: 1. Once you have published your pages, make sure your WebSphere Application Server and Web server are both started. 2. Inside the WebSphere Studio, right-click the ordersinput.html, and select Preview File with->netscape. Your page should look similar to the example in Figure 316. Figure 316. ordersinput.html displayed in Netscape 3. Enter a valid customer ID. Type Click the Submit button, and you should see a page that looks like the example in Figure 317. Figure 317. ordersresults.jsp displayed in Netscape If you get an error page or something that you did not expect, try restarting the WebSphere Application Server and republishing the site. Now we should test the orderline page. Follow these steps: 1. Right-click on the orderlineinput.html, and select Preview File with ->Netscape. The input page should look like the display in Figure 318 on page 356. ABC Company Web site design and development 355

366 Figure 318. orderlineinput.html displayed in Netscape 2. For orderid, type in a value of Click the Submit button. The result page should look like the display in Figure 319. Figure 319. orderlineresults.jsp displayed in Netscape Joining the order status with the order line In this section, we join the ordersresults.jsp file to the orderlineresults.jsp. Follow these steps: 1. In the WebSphere Studio, double-click on the ordersresults.jsp file. This checks it out and opens it in the Page Designer. The page should look like the display in Figure 320. Figure 320. ordersresults.jsp open for editing 2. You do not need to display the Order ID to the customer. Right-click on the JSP tag inside this column, and select Delete. 356 Web Enabling AS/400 Applications with IBM WebSphere Studio

367 3. Select the Order ID heading text, and press the Delete key. 4. Type View Order in the top right heading cell of the table. 5. Select Insert->Form and Input Fields->Push Button->Submit button. Enter View order details for the label and orderline for the name. In the Submit button attribute dialog box, click OK. We now need to get the parameters that we need to pass to the orderlineresults.jsp page. Complete these tasks: 1. In the WebSphere Studio, double-click on the orderlineinput.html file. This checks the file out and opens it in Page Designer. The page should appear as shown in Figure 321. Figure 321. orderlineinput.html open for editing 2. Double-click on the field next to the orderid caption. This opens the Text Field Attribute box. 3. Make a note of the name listed. The name should be orderid. You will need this information later in this section. 4. Click in the drop-down list box next to the Tag caption, and select Form. This takes you to the form properties. 5. Make note of the Action field. The action should be /servlet/orderstatus.orderline, provided you followed the wizards correctly earlier. Click OK. We now have the information we need to be able to join the ordersresults.jsp file to the orderlineresults.jsp file. Follow these steps: 1. Return to the Page Designer where the ordersresults.jsp page should still be open. If it is not, double-click on the ordersresults.jsp file in the WebSphere Studio. 2. Double-click on the View order details button. Click the drop-down list box next to the Tag caption at the top of the Push Button Attribute dialog box, and select Form. 3. For the action of this form, type /servlet/orderstatus.orderline (noted earlier). 4. Set Method to Post. 5. Click on the Hidden Fields tab at the top of the page. 6. Enter orderid for the hidden field name. ABC Company Web site design and development 357

368 7. For the value field, select the Specify by property check box, and click the Browse... button. 8. In the Bean Property Selection, select the bean property APILIB_ORDERS_OID(). Click OK. 9. Click the ADD button. You should see your parameter added as a hidden field. 10.Click OK in the Form Attributes dialog box. Your page should now look like the example in Figure 322. Figure 322. ordersresults.jsp after modification 11.Save this page and exit Page Designer. In WebSphere Studio, right-click on the orderstatus directory, and select Check In. 12.Right-click on the orderstatus directory, and select Publish whole project Testing the order status subsite We are now ready to test the two pages that we joined. We use this process: 1. Right-click on the ordersinput.html file, and select Preview File with-> Netscape. You should see a page like the example in Figure 323. Figure 323. ordersinput.html displayed in Netscape 2. Enter 0011 for the custid parameter. Click Submit. You should see the page shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

369 Figure 324. ordersresults.jsp displayed in Netscape 3. Click on the first View order details button. You should see the page shown in Figure 325. Figure 325. orderlineresults.jsp displayed in Netscape ABC Company Web site design and development 359

370 360 Web Enabling AS/400 Applications with IBM WebSphere Studio

371 Chapter 8. Creating the complete ABC Company Web site In Chapter 7, ABC Company Web site design and development on page 157, we developed the subsites to be integrated into the complete ABC Company Web site. Now that we have the subsites and navigation, we need to develop the look and feel of the Web site. 8.1 Web site development: Issues and pitfalls This section discusses the issues involved in Web-site design and production, and how to avoid common mistakes. The main goal is to give users a reason to keep visiting the Web site. The key points to creating a good Web site include several design objectives Design objectives This section discusses Web site development issues in regard to design Information architecture WebSphere Studio can be used to create storyboards and show the Web site structure. You may want to consider having an index for the Web site. The pages directly below the main page can act as categories. Then, each page under one of these pages will describe this area of the Web site in more detail. Example guidelines include: Create a Web site branching diagram or storyboard that shows what pages the Web site includes. Consider how the information will be organized and how it will be accessed by the user. Group information into categories Design issues Users can usually connect to the Web site through any page. This can be limited through cookies, scripts, and access control. Users do not always follow a particular linear path through the Web site. Make sure that each page has enough information about the company or the Web site so that when a user arrives at a page in the Web site, they know what to do and how the page may serve them. Example guidelines include: Users can choose their own path though the Web site: MayrevisittheWebsiteviaabookmark Can mark areas to be navigated to and from any page The contents of a Web site should changed at a regular and predictable time. Giveusersareasontokeepvisitingyoursite Interface design The right impression is not necessarily a good impression. Example guidelines are: Consider how your Web site is presented to the user. Make the right impression. Copyright IBM Corp

372 Use standard Web navigation techniques: Icons: Home, Search, Mailbox Typical company information, such as Home, News, Products, Employment, About Be consistent in the format for the Web site. WebSphere Studio will help. Page architecture considerations: Create the look and feel Lay out the contents on the page Provide navigation to other pages through buttons or icons in the document that link back to the parent document or forward to the next topic Content negotiation Each time a browser requests a page from a Web server, the browser sends information about itself (User Agent) along with the request. This information can be used to send the appropriate page for a given browser. You can design versions of the Web site based on particular browser capabilities, such as frames or text only. You can also design versions of the Web site for connection speeds, such as low bandwidth or high bandwidth. However, the user must pick the version of the Web site, the server has no easy way of determining the connection speed. An example guideline is content negotiation, whichisthe process of creating versions of pages in the Web site. It includes: Supporting different browser features Different network bandwidth (text only versus rich media) User preferences Regionalization (NLS) Authentication and security Linking You can also use HTML tags to specify alternative actions. ALT tags show up as fly-over help in some browsers so you should always use them. Example guidelines are: The initial page of information should be high level. TOC, headlines, attractive Linking should be used to get more detailed information Content of a document should be able to be read without the links or the images: Usually avoid such phrases as "Click here. Use ALT tags where appropriate. Instead of copying information, link to it. 362 Web Enabling AS/400 Applications with IBM WebSphere Studio

373 8.1.2 Production This section discusses Web site development issues in regard to production Form and content Example guidelines are: The information is displayed and read on paper, so keep it simple. Make information easy to read. Create chunks of information that are organized and grouped. Other guidelines include: Compare style guides. Many HTML and Web style guides available. Use ordered lists for procedures and unordered lists for a set of choices Content Example Guidelines are: Avoid: Making the user scroll Welcome messages Introductory paragraphs Concentrate on providing facts View on paper Example guidelines are: Consider providing a PostScript or Acrobat file if users will typically print the information. If users want to print a group of pages at once, create an Acrobat or PostScript version of the file Production issues Example guidelines are: Consider images and other media: Require more bandwidth; should have high-impact content. Consider providing a text-only alternative. Use industry standard formats (GIF, JPEG, MP3) Consider users with special needs: Consider media to improve accessibility. Investigate IBM Special Needs Solutions to improve accessibility. It is locatedonthewebat: Images Example guidelines are: Interlaced images let the user see portions of the image sooner. Multipart GIFs provide simple animation. Trade-offs in image size and quality need to be made. Browsers cache images on the client machine s disk and memory. Creating the complete ABC Company Web site 363

374 Provide a textual alternative to image maps, and avoid using a large image map for the initial page (performance). Use ALT, HEIGHT, and width elements in the IMG tag: ALT string shows up if images are disabled ALT string appears as fly-over help HEIGHT and width permits layout prior to image loading Multimedia Many media types are supported by browser plug-ins. Example guidelines are: Audio and video can enhance the Web site. Should be central to the Web site goals (due to performance impact), for example, music (CD) stores, real estate (house walk-throughs). Streaming audio and video formats are most appropriate on the Web. Only a portion of the clip is required at the browser at any time Testing The staging server should duplicate the server environment as much as possible, including a firewall, if applicable. Example guidelines are: Create a staging server that duplicates the server structure. Test, test, and test some more: Different platforms and different browsers Graphics on and off HTML verification Prepare graphics and other media for low-bandwidth transmission Create and test links Test over the Internet Publicizing Example guidelines are: Register memorable domain names. Register common variants of the company name. Register with such search services as Yahoo. Look for other sites on the Web that attract the same audience and let them know about your Web site. Modify HTML for Web crawlers; can be set to not allow a bookmark (META-TAG). Propose that the Web site be listed as a cool or new site Evaluating the Web site Example guidelines include asking these questions: Is there a logical structure of the Web site? One page should equal one topic. Is the information grouped into meaningful categories? Show a list of content categories, typically no more than about seven. 364 Web Enabling AS/400 Applications with IBM WebSphere Studio

375 Does the home page tell the user what the Web site has to offer? Trade-off: Link to all Web site content versus keeping the home page simple. Can information be found and retrieved easily and quickly? The user should be able to get to the information in three clicks or less. We have tried to employ these simple and easy to follow ideas across all pages in the ABC Company Web site sample project. 8.2 Creating static pages This section discusses static page creation techniques using WebSphere Studio Content of static HTML pages As explained earlier, we have a few pages that are static and represent who the company is and try to build credibility with new customers. It is good to give the company history and establish that the company is real. Another good item to put on every single page is the company address and contact number. This allows people to find out who the company is and speak to someone if they have questions, comments, or concerns. We need to create a new project for the static subsites. Follow the same process outlined in 3.1.1, Creating a new project on page 24, for creating a new project, but use these parameters: 1. Type Static as the name of the name of the project. 2. Enter C:\Static as the name of the project folder. 3. Select <none> for the project template. A new project will be created called Static Working with existing pages Some static pages were created earlier in 3.3.2, Constructing the Logon page on page 97. This was done to give you a feel for how to use Page Designer and WebArt Designer. We use the techniques covered in those sections to build our static pages. To import these files, complete the following steps: 1. Click on the Static folder in the WebSphere Studio. 2. Select Insert->File. 3. Click on the Use Existing tab. You are presented with the Insert File dialog box shown in Figure 326 on page 366. Creating the complete ABC Company Web site 365

376 Figure 326. Inserting existing files into a new project 4. Click the Browse button. 5. You should now see an Open dialog box window. Browse to select the files used in 3.3.2, Constructing the Logon page on page 97. Then, click the Open button. The files should be: \DemoCompany\ABC_Comapny\Logon.html \DemoCompany\Images\banner.html \DemoCompany\Images\general.mif 6. Deselect the Remove the original file after copying check box. Then, click OK. 7. The files should now be entered into your static subsite. Double-click on Logon.html. It should be checked out and opened in Page Designer. The page should look like the example in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

377 Figure 327. Page Designer: Logon page template 8. Close the Page Designer window Creating the Web site template file We now need to take this sample page and change it in to a template so we can work with it later. Follow these steps: 1. In WebSphere Studio, right-click the Logon.html file, and select Copy. 2. Right-click on the Static folder, and select Paste. You should be given a file called Copy-1-of-Logon.html. 3. Select the Logon.htm file. Right-click on it, and select Delete... The dialog box shown in Figure 328 appears. Figure 328. Delete files dialog box 4. Leave the option Delete from disk selected, and click the OK button. 5. Click Yes to All if you are asked about breaking any links. 6. Right-click on the Copy-1-of-Logon.html file, and select Rename. Forthe new name of this file, type WebsiteTemplate.html. Creating the complete ABC Company Web site 367

378 You should now have a project that looks like the example in Figure 329. Figure 329. WebSphere Studio project after creating the template file Modifying the HTML file We now need to modify the WebsiteTemplate.html file and store it as a template. ThetechniqueformakingaHTMLfileavailableasatemplateiscoveredin3.3.3, Creating a page template on page 102. Follow these steps: 1. Double-click the WebsiteTemplate.html file. This checks it out and opens it in Page Designer. 2. You should see that all the images for this file are missing. Do not worry about this for now since we are really only interested in the table layout on this page. The page should look like the example in Figure 330. Figure 330. Page Designer: Template page before modifications 3. Right-click on one of the broken images. These are the boxes that have the big red cross through them. Select Delete. 368 Web Enabling AS/400 Applications with IBM WebSphere Studio

379 4. Repeat step 3 for all of the broken images. 5. Right-click on the table that contains the Submit and Reset buttons. Select Delete. 6. Right-click on the table that contains the user ID and password fields. Select Delete. 7. You are now left with the element inside the bottom right cell. Right-click on the form, and select Delete. 8. Double-click inside the bottom right cell to view the Attributes of this cell. Select Left for the Horizontal Alignment and Top for Vertical Alignment. 9. Double-click inside the table in the bottom left. Be careful to select the outside table and not the inside button layout table. In the cell Attribute window, select Left for the Horizontal Alignment and Top for the Vertical Alignment. The page should contain two empty tables and look like the example in Figure 331. Figure 331. Page Designer: Empty template file 10.Click in the top left cell of the page, and select Insert->Image. Select the book.gif image from the Open dialog box, and click the OK button. 11.Click in the bottom right cell, and select Table->Add Row->Add Below Cell. 12.Click in one of the newly added cells. Hold down the Shift key, and click in the other newly created cell. They should both be highlighted. 13.Right-click in either of the highlighted cells, and select Join Selected Cells. 14.Double-click in the new long cell at the bottom of the table. Inside the Attribute dialog box on the cell attribute page, select Center for horizontal alignment and Top for vertical alignment. Close this dialog box. 15.Enter the company details in the bottom cell. Type the following information: ABC Company 1234 Main St Anywhere USA Phone (111) Fax (111) Creating the complete ABC Company Web site 369

380 16.Save this file, and exit the Page Designer. 17.Right-click on the Static folder in the Studio Workbench, and select Check In. We are now ready to make this file into our first template for our Web site. Follow the process described in 3.3.3, Creating a page template on page 102, to make this page in to a page template. Rename the page to ABCCompanyTemplate.html. We use this template to create more specific templates for the subsites. This is a slightly clumsy process, but it forces our Web site to be consistent across all pages Creating images for all links After looking at the subsite requirements, we can determine the links we need to have. All the links are navigated with images so we need an image for each link. We already discussed how to use the WebSphere WebArt Designer to create the images for the links. Now we decide on the captions for these images. In 8.2.2, Working with existing pages on page 365, we imported the template navigation image files called general.mif and banner.mif. In this section, we edit the general.mif file to give us all our links that we will use. Follow this process: 1. In the Studio Workbench, click on the Static folder, and select Insert->Folder. 2. In the text field under folder name, type Images, and click the OK button. This creates an Images folder inside the Studio Workbench. 3. In the Studio Workbench, double-click the general.mif file. This checks it out and opens it in the WebSphere WebArt Designer. The general.mif file should have a small blue circle and a caption which looks similar to the example Figure 332. Figure 332. WebArt Designer: Opening the general.mif file 370 Web Enabling AS/400 Applications with IBM WebSphere Studio

381 4. Double-click the About Us caption to open the Edit Logo Object dialog window. Then, in the text field, type Welcome. 5. Close the Edit Logo Object dialog window. 6. Select File->Save Wizard. MakesuretheObject Only option is selected, and click the Next button. 7. In the next wizard page, make sure the GIF option is selected. Then, click the Next button. 8. Click Finish. 9. IntheSaveAsdialogbox,findthe\Static\Images project folder. Type welcome.gif for the file name. 10.Make sure both the Add to WebSphere Studio and Make source link check boxes are selected. Click the Save button. 11.Repeat steps 4 through 10, changing only the caption and the GIF file name. The information is provided in Table 45. Table 45. Input information for creating the button images Button Input information Welcome About Us Catalog Login Logout Generate New User Shopping Cart Purchase Order Status Caption: Welcome File: welcome.gif Caption: About Us File: aboutus.gif Caption: Catalog File: catalog.gif Caption: Login File: login.gif Caption: Logout File: logout.gif Caption: Generate New User File: newuser.gif Caption: Shopping Cart File: shoppingcart.gif. Caption: Purchase File: purchase.gif Caption: Order Status File: orderstatus.gif. 12.Close the WebArt Designer window. 13.From the Studio Workbench, select the Images folder. Then, select Insert->File from the pull-down menu. From the Insert File dialog window, click the Use Existing tab, browse to the location where you stored the book animation GIF file (bookani.gif). Select it, and click the OK button. Now we modify the banner.mif file to produce two different banners. One of the banners identifies to the user that they are on the registered user page. The other banner identifies the normal site. Follow these steps: Creating the complete ABC Company Web site 371

382 1. In the Studio Workbench, double-click the banner.mif file.thischecksitout and opens it in the WebSphere WebArt Designer. The banner.mif file should have a small blue circle and a caption that looks similar to the example in Figure 333. Figure 333. WebArt Designer: ABC Company general area banner 2. Double-click on the bottom ABC Company text to open the Edit Logo Object properties window. Set the font size to Close the Edit Logo Object dialog window. 4. Resize the blue cycle, so the ABC text fits into it. 5. Select File->Save Wizard. Make sure the Object Only option is selected, and click the Next button. 6. In the next wizard page, make sure the GIF option is selected. Then, click the Next button. 7. Click Finish. 8. IntheSaveAsdialogbox,findthe\Static\Images project folder. Type banner.gif for the file name. 9. Make sure both the Add to WebSphere Studio and Make source link check boxes are selected. Then, click the Save button. We now need to modify this image so that we have an alternative banner. The alternative banner will indicate to the user they are in the registered user area of the ABC Company Web site. We use this process: 1. Click on the ABC Company text, and select Edit->Copy. 2. Select Edit->Paste. Now move the image that has just been pasted and position it underneath the existing ABC Company word. The window should look like the display in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

383 Figure 334. WebArt Designer: Creating the ABC Company user area banner 3. Double-click on the bottom ABC Company text to open the Edit Logo Object properties window. Type Registered User Area. Set the font size to Click the Color tab. From the group-drop down list box, select Gradation. From the type list, select monotone. 5. Click the Outline tab, and select None for Type. 6. Click on the Logo Effect tab, and select Drop Shadow. SetDirectiontoLeft, Strength to 1 notch from the left, the X and Y distances are both to 1 pixel, and Color to black. All of this information is shown in Figure 335. Figure 335. WebArt Designer: Logo effect properties 7. Close the Edit Logo Object window, and position the new label to the right-hand side under ABC Company text. The final result should look like the display in Figure 336 on page 374. Creating the complete ABC Company Web site 373

384 Figure 336. WebArt Designer: ABC Company registered user area banner 8. Select File->Save Wizard. Make sure the Object Only option is selected, and click the Next button. 9. In the next wizard page, make sure the GIF option is selected. Then, click the Next button. 10.Click Finish. 11.In the Save As dialog box, find the \Static\Images project folder. Type registeredbanner.gif for the file name. 12.Make sure both the Add to WebSphere Studio and Make source link check boxes are selected. Then, click the Save button. 13.Close the Page Designer window. 14.From the Studio Workbench, check in all files in the Static project folder. We now have all the images we are going to use to produce the ABC Company Web site templates. 8.3 Creating the normal and registered user templates This section explains how to create templates for normal and registered user areas. Normal pages are HTML files, and registered user pages are JSPs Normal page templates At this point, the Static project in the Studio Workbench should look like the display in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

385 Figure 337. Studio Workbench: Static project status Make sure all the GIF files have been checked in. This means that the files can be published. We are going to use this current directory structure throughout the entire Web site. This is important to remember because once we start to build templates that have images in them, we can only use those templates inside of a Web site that has the same image directory structure. We now see how to build these templates: 1. Click on the Static folder in the Studio Workbench, and select Insert->File. You should see the ABCCompanyTemplate.html file. If you do not see this file, review 8.2.2, Working with existing pages on page 365, to see how to create this file. 2. Click on this file, and type staticpagetemplate.html for the file title. Click OK. The file should be added to the Studio Workbench. 3. Double-click the staticpagetemplate.html file. This checks it out and opens it in the Page Designer. The page should look similar to the example in Figure 338 on page 376. Creating the complete ABC Company Web site 375

386 Figure 338. Page Designer: Empty template page 4. Try to set up your monitor so that you can see the Studio Workbench and the Page Designer. Select the image in the Studio Workbench called banner.gif. Drag it across to the top right cell of the table in the Page Designer. If you have difficulty dragging between Studio Workbench and the Page Designer, you can select Insert->Image inside the Page Designer. 5. In the Studio Workbench, select the image called welcome.gif. Dragthis across to the Page Designer and drop it in the second cell of the inside table. The page should look like the example in Figure 339. Figure 339. Page Designer: Creating the static template 376 Web Enabling AS/400 Applications with IBM WebSphere Studio

387 6. We now want to repeat step 5 for the following files: aboutus.gif history.gif catalog.gif login.gif newuser.gif. If you run out of cells on the inner table, click on the bottom cell, and select Table->Add Row->Add Below Cell. 7. The final image to add is the book animation. Drag the bookani.gif image from the Studio Workbench, and drop it in the top left cell of the table. 8. Set the spacer cell at the top of this table to give the first image some space from the top. Double-click in the first cell on the inner table, which is just above the welcome image. On the Cell Attribute window, set the height to 30. Your page should look like the example in Figure 340. Figure 340. Page Designer: Completed static template page 9. Save this file, and exit the Page Designer. In the Studio Workbench, right-click on the Static folder, and select Check In. You are now ready to make this file a template for the ABC Company Web site. Follow the process described in 3.3.3, Creating a page template on page 102, to make this page a template. Leave the file name as staticpagetemplate.html Registered user templates We now need to generate a template that we can easily use for all our registered user subsites. We follow a similar process to what we did in the last section, but there are some variations: Creating the complete ABC Company Web site 377

388 1. Click on the Static folder in the Studio Workbench, and select Insert->File. You should see the ABCCompanyTemplate.html. If you do not see this file, review 8.2.2, Working with existing pages on page 365, on how to create this file. 2. Click on this file, and type dynamicpagetemplate.html for the file title. Click OK. The file should be added to the Studio Workbench. 3. Change the file extension since all the registered users are JSPs. Right-click on the dynamicpagetemplate.html file, and select Check In. 4. Right-click on the dynamicpagetemplate.html file again, and select Rename. Enter the new file name dynamicpagetemplate.jsp. You should be presented with the dialog box shown in Figure 341. Click the Yes button.itis important that you change the MIME type. Figure 341. MIME type change warning 5. In the Studio Workbench, double-click on the dynamicpagetemplate.jsp file. This checks the file out and opens it in Page Designer. 6. Drag the image called registeredbanner.gif from the Studio Workbench to the Page Designer. This image goes in the top right cell. This new banner takes the place of the banner.gif in the static pages. 7. In Page Designer, click in the second cell of the inner table. Select Insert->Form and Input Fields->Push Button->Image Button. Youare presented with the dialog box shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

389 Figure 342. Push button attribute dialog box 8. Click on the Browse... button next to the Image File field. You need to navigate to the Images directory inside the Static project directory. Select the shoppingcart.gif file, and then click the OK button. 9. Click in the Name field, and type shoppingcart. 10.Click OK in the Push Button Attribute window. The page should now look like theexampleinfigure343. Figure 343. Page Designer: ABC Company registered user template page in progress Creating the complete ABC Company Web site 379

390 11.Click on the HTML Source tab at the bottom of the Page Designer. You now see the HTML code that makes up this page. Find the line of HTML that looks like: <INPUT type="image" name="shoppingcart" src="file:///f:/redbook/static/images/shoppingcart.gif"> Change it to look like: <INPUT type="image" name="shoppingcart" src="file:///f:/redbook/static/images/shoppingcart.gif" border="0">. This ensures there is no border around your image when people look at the page. 12.Repeat step 7 through step 11 for the following images: catalog.gif purchase.gif orderstatus.gif logout.gif. Set the names of these files to the file names but without the GIF extension. Do not forget to set the border to 0 for each item. 13.The final image to add is the book animation. Drag the bookani.gif image from the Studio Workbench, and drop it in the top left cell of the table. 14.Set the top cell of the inner table to have a height of 30 just as you did before. The final page should look like the example in Figure 344. Figure 344. Page Designer: ABC Company registered user area page 15.Save this file, and close Page Designer. 380 Web Enabling AS/400 Applications with IBM WebSphere Studio

391 16.Right-click on dynamicpagetemplate.jsp, and select Check In. We are now ready to make this file a template for the ABC Company Web site. Follow the process described in 3.3.3, Creating a page template on page 102, to make this page a template. Leave the file name as dynamicpagetemplate.jsp Session management servlet, login servlet, and custid bean The servlets used here will get their configuration information from the WebSphere Application Server. We refer to the servlets by alias. Follow these steps: 1. Place the cursor at the top of the page. Select Insert->Servlet. Youshould see the dialog box shown in Figure 345. Figure 345. Servlet attribute dialog box 2. In the Name field, type check. In the Code field, type check. This calls the alias that does the user validation on each page. Click OK. 3. Next to the first JSP tag, select Insert->JSP Tags->Insert a Bean. You should see a dialog box like the one in Figure 346 on page 382. Creating the complete ABC Company Web site 381

392 Figure 346. JSP attribute dialog box 4. For the name field, type custidbean. In the Type field, enter Session.CustIDBean. Select the No Introspection and Create radio buttons. Make sure the scope is set to session, and click the OK button. 8.4 Assembling the ABC Company Web site Now that the templates have been developed, we can use them to begin the generation of the static pages. Follow these steps: 1. To create a new project for the ABC Company Web site. Follow the same process described in 3.1.1, Creating a new project on page 24, for creating a new project, but use the following parameters: a. Type ABCCompany for the name of the name of the project. b. Enter C:\ABCCompany as the project folder. c. Leave project template as <none>. A new project is created called ABCCompany. 2. In the Studio Workbench, click on the ABCCompany folder. Select Insert->Folder In the Insert Folder dialog box, click on the Use Existing tab. The dialog box should look like the one in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

393 Figure 347. Studio Workbench: Insert folder dialog box 4. Click the Browse... button, and navigate to the Static folder that we used in the previous section. Inside the Static folder, click on the Images folder, and click the OK button. 5. The folder name should now be displayed in the Folder Name field. Click the Add button, and then click the OK button. We should now have the Images folder added to the ABCCompany project folder. This allows us to work with our existing templates without breaking any image links. Follow these steps: 1. In the Studio Workbench, click on the ABCCompany folder. Select Insert->Folder. 2. In the Insert Folder dialog box, type StaticPages for the folder name. You are now ready to begin adding some pages that you are going to use. 3. Click on the ABCCompany folder in the Studio Workbench. Select Insert->File. 4. In the Insert File dialog box, select the staticpagetemplate.html file. If this is not present, review 8.3, Creating the normal and registered user templates on page 374. For the file name, type index.html, and click the OK button. 5. Select View->Relations, and then click on the index.html file. There should not be any broken links between this file and the images. The Studio Workbench should look like the display in Figure 348 on page 384. Creating the complete ABC Company Web site 383

394 Figure 348. Studio Workbench: ABC Company project with files and relations view 6. Add all the other files that you want to use in the static section of the Web site. Repeat steps 3 and 4 using the following parameters for the page names: aboutus.html history.html catalog.html login.html logout.html newuser.html 7. Select all of these.html files, and drag them to the StaticPages folder. All image links will be updated automatically. If you put the files directly in that folder, then the WebSphere Studio would not have known the correct images to use. 8. Select View->Relations. Then, browse through the StaticPage folder making sure there are no broken links. You should even note the correct reference to the Master.css file Adjusting the links on the static pages This information is to be applied across all of the static pages that have just been created. Follow these steps: 1. Double-click the index.html file in the Studio Workbench to open it in Page Designer. 2. Right-click on the image that has the caption Welcome, andselectdelete Row. 3. Click the About Us image, and select Insert->Link. You are presented with the Link Attribute dialog box. Click on the To URL tab, and you should see the dialog box shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

395 Figure 349. Link Attribute dialog box 4. Go back to the Studio Workbench, and right-click on aboutus.html, which can be found in the StaticPages folder. Select Copy as URL text. 5. Return to the Page Designer, and right-click inside the URL field next to the Browse button. Select Paste. 6. Click the OK buttononceyouhavetheurlinplace. 7. Repeat the process for all the links using the information given in Table 46. Table 46. Linking static HTML pages Page What to do with the links index.html aboutus.html catalog.html Welcome - Delete row About Us - /StaticPages/aboutUs.html history - /StaticPages/history.html catalog - /StaticPages/catalog.html Login - /StaticPages/login.html New Users - /StaticPages/newUsers.html Welcome - /StaticPages/index.html About Us - Delete row history - /StaticPages/history.html catalog - /StaticPages/catalog.html Login - /StaticPages/login.html New Users - /StaticPages/newUsers.htm Welcome - /StaticPages/index.html About Us - /StaticPages/aboutUs.html history - /StaticPages/history.html catalog - Delete row Login - /StaticPages/login.html New Users - /StaticPages/newUsers.htm Creating the complete ABC Company Web site 385

396 Page history.html login.html logout.html newuser.html What to do with the links Welcome - /StaticPages/index.html About Us - /StaticPages/aboutUs.html history - Delete row catalog - /StaticPages/catalog.html Login - /StaticPages/login.html New Users - /StaticPages/newUsers.htm Welcome - /StaticPages/index.html About Us - /StaticPages/aboutUs.html history - /StaticPages/history.html catalog - /StaticPages/catalog.html Login - Delete row New Users - /StaticPages/newUsers.htm Welcome - /StaticPages/index.html About Us - /StaticPages/aboutUs.html history - /StaticPages/history.html catalog - /StaticPages/catalog.html Login - /StaticPages/login.html New Users - /StaticPages/newUsers.htm Welcome - /StaticPages/index.html About Us - /StaticPages/aboutUs.html history - /StaticPages/history.html catalog - /StaticPages/catalog.html Login - /StaticPages/login.html New Users - Delete row 8. Once this is completed, look through the Studio Workbench with the relations view selected. Check each of the pages, and make sure all the links are connected. You should look for a view like the one shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

397 Figure 350. Studio Workbench: ABC Company project with a relations view Notice how all the lines between all the files are solid. Now that the pages are linked, the WebSphere Studio will manage these links. You can move files where ever you choose inside the WebSphere Studio and the links are automatically updated. Hint We could have defined all the links in the templates and then we would have only needed to delete the rows for the links we did not need. This can make the job much faster, but you need to plan ahead to make it a worthwhile venture. If you do not plan ahead sufficiently, you can spend more time fixing the Web site broken links Modifying the Welcome page To modify the Welcome page, follow these steps: 1. In the Studio Workbench, double-click the index.html file. This checks out the file and opens it in the Page Designer. 2. Double-click in the middle right cell of the table. This shows the Attributes table. Select Center for the horizontal alignment. Click OK. 3. Press Enter once in the same cell, and then type Welcome. 4. Double-click the text you just entered. This opens the Physical Emphasis Attribute dialog box shown in Figure 351 on page 388. Creating the complete ABC Company Web site 387

398 Figure 351. Physical emphasis attribute dialog box 5. Select +2 for the font size from the drop-down list box. 6. Select the Bold check box. Then click the OK button. 7. Press Enter twice, and then enter the following text: Welcome to the ABC Company. We hope that you enjoy your visit with us. If you need to contact us for anything, do not hesitate to call us at the telephone number listed at the bottom of every page. This text tries to establish some form of trust with the user by telling them that they can find out who you are and that you are not trying to hide from them. 8. Press Enter three times, and then enter the following text: If you have already registered with us, you can simply click on the Login link on the left-hand side. This text tells existing users how to navigate the ABC Company Web site simply if they do not understand what the links mean down the side. 9. Press Enter twice, and then enter the following text: If you are new to our Web site, we recommend that you click on the New Users link. This text tells the new users where to begin if they are not too sure. 10.Select Edit->Spelling. This spell checks your document Modifying the About Us page Complete the following steps to modify the About Us page: 1. In the Studio Workbench, double-click aboutus.html. This checks out the file and opens it in Page Designer. 2. Set the aboutus.html file the same way as the index.html page with the heading in bold and everything centered. Remember to type About Us, instead of welcome. 388 Web Enabling AS/400 Applications with IBM WebSphere Studio

399 3. Type the following text: About Us We are an American company that has been distributing our products to people for over the past 100 years. We take pride in our work and thrive on customer satisfaction. The ABC Company is a wholesale supplier with our warehouse located at: 1234 Main St Anywhere USA The ABC Company wants to deliver huge discounts directly to the public through our Internet initiative scheme. This text tells the user again where the warehouse is and what the company is trying to do. It is always good to have company mission statements and objectives here and even comments and feedback that have come from the customers Modifying the History page To modify the History page, follow these steps: 1. In the Studio Workbench, double-click on history.html. This checks out the file and opens it in Page Designer. 2. Set the history.html file the same way as the index.html page with the heading in bold and everything centered. Remember to type History instead of welcome. 3. Type the information about the history of the company. Refer to Chapter 4, Restoring the ABC Company Web site sample project on page 121, if you want sample text Modifying the Logout page Complete these tasks to modify the Logout page: 1. In the Studio Workbench, double-click on the logout.html. This checks out the file and opens it in the Page Designer. 2. Set the logout.html file the same way as the index.html page with the heading in bold and everything centered. Remember to type Logout instead of welcome. 3. Type the following text: Thank you for shopping with the ABC Company. Any orders that you placed should be shipped within two working days. This indicates to the user when they should expect their items that they may have purchased. It would be better to convert this page to a JSP and give the user specific information about their actual purchase. For this example, it was not necessary. 8.5 Tying it all together We now have all of the subsites. This section links all of the subsites together and adds some presentation. This can take a little bit of time, but some of the features in the WebSphere Studio make it very easy. Creating the complete ABC Company Web site 389

400 8.5.1 Importing the subsites Follow these steps to import all subsites into the ABC Company project: 1. In the Studio Workbench, select File->Open Project. Gotothe \ABCCompany folder, and select the ABCCompany.wao file. 2. Click the Open button. You should see a project that looks similar to the display in Figure 352. Figure 352. Studio Workbench: ABC Company project before adding the subsites 3. The first stage for updating this project is to import the directories you have already created. In the Studio Workbench, select the project folder ABCCompany. 4. Select the menu Insert->Folder. In the Insert Folder dialog box, click the Use Existing tab. 5. Click the Browse button, and find the following subsites: \subsites\catalog \subsites\generalcatalog \subsites\newuser \subsites\orderpurchase \subsites\orderstatus \subsites\shoppingcart \subsites\session The Insert Folder dialog box should look like the example in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

401 Figure 353. IStudio Workbench: Insert Folder dialog box 6. Do not add the Static subsite since it has already been added to the ABCCompany project. Click the OK button Cleaning up subsites We now need to move some folders around inside the WebSphere Studio and delete some folders. Follow these steps: 1. Select View->Relations, and click on viewallcatalogitemserror.jsp. You can see that it has a relationship with master.css and \servlet\catalog\viewallcatalogitemsdbbean.class. 2. Right-click on the master.css link, and select Edit Link. You get an Edit Link dialog box that should show \theme\master.css. This means that the theme folder is referenced in the root structure and not inside the catalog folder. 3. Go through all of the subsite folders, right-click on the theme folder, and select Delete. You see the dialog box shown in Figure 354. Figure 354. Delete file dialog box 4. Click the Yes button, and the theme folder is deleted. 5. You should now have only one theme folder in the entire ABCCompany project. Repeat the above process and delete the _libraries folder also found in each of the subsite folders. Creating the complete ABC Company Web site 391

402 8.5.3 Organizing the servlet folders We now need to move the servlet folders to their correct location. You may recall that the servlet folder when published goes to a different location than the HTML pages. Follow these steps: 1. In the Studio Workbench, click and expand the catalog folder. There should be a folder called servlet inside. 2. Click and expand the servlet folder. There should be another catalog folder. This folder contains all of the servlets for the catalog subsite. 3. Click and drag the catalog folder down to the colored servlet folder as shown in Figure 355. Drag this directory To the servlet directory Figure 355. Studio Workbench: Dragging files in the ABC Company project 4. Right-click the servlet folder inside the catalog folder, and select Delete. Click the Yes button in the Warning dialog box. 5. Click on each of the.html and JSP files inside the catalog folder making sure that all the files have solid links to the files they reference. Repeat this process for all the other folders that contain servlets Fixing broken references Until now, we have not had any broken references to deal with. If, by some chance, you had broken links earlier in this section, we now explain how to fix them. Here are the steps you need to follow: 1. In the Studio Workbench, expand the servlet folder, and then expand the catalog folder. 2. Select View->Relations. Click on each of the files in this folder looking for broken links. You should find that only the.servlet files have broken links as shown in Figure Web Enabling AS/400 Applications with IBM WebSphere Studio

403 Figure 356. Viewing broken links for servlet files in the ABC Company project 3. Click on viewallcatalogitems.servlet, and inspect the links. Make sure this item is not checked out. 4. In the Relations view, look at the first broken link. It should read \viewallcatalogitemsresults.jsp. This is the file that will be called for the result of the JSP. Right-click on the box with the? (question mark), and select Edit Link. 5. Inside the Edit Link dialog box, add \catalog. Click the Yes button. The full path should now read \catalog\viewallcatalogitemsresults.jsp. If you get a warning box, click the Yes button. 6. The link should now be solid. Repeat the above process for all of the other servlet configuration files listed inside the catalog servlet folder. 7. Modify all the other servlet configuration files. Repeat the above process but, instead of using \catalog at the start of the path, use the subsite name. For example, in the orderstatus folder, use \orderstatus. There should be no pages left with broken relationships Adding registered user templates We now need to format our pages to have a common look and feel. This is achieved by using the dynamic templates that were created earlier in 8.3.2, Registered user templates on page 377. Follow these steps: 1. In the Studio Workbench, click on the catalog subsite. 2. Select Insert->File. From the Insert File dialog box, click on dynamicpagetemplate.jsp. Click OK. Creating the complete ABC Company Web site 393

404 3. The dynamicpagetemplate.jsp will now be added to the catalog subsite. Double-click the dynamicpagetemplate.jsp file to check it out and open it in Page Designer. 4. Go back to the Studio Workbench, and double-click viewallcatalogitemserror.jsp to check it out and open it in Page Designer. 5. In Page Designer, while looking at viewallcatalogitemserror.jsp, select Edit->Select All. 6. Select Edit->Copy. Close this file. If you are asked whether you want to save this page, click the No button. 7. After closing the previous page, you should now see dynamicpagetemplate.jsp. Click inside the middle right cell, and select Edit->Paste. The top of the page should look like the display in Figure 357. Figure 357. viewallcatalogitemserror.jsp converted to dynamicpagetemplate.jsp 8. Save this file, and exit Page Designer. 9. Check in the checked out files in the Studio Workbench by right-clicking on them and selecting Check In. 10.Take note of the file that we just copied the information out of and delete that file. Right-click on viewallcatalogitemserror.jsp, and select Delete. Select the option to delete from disk, and click the OK button. 11.Right-click the dynamicpagetemplate.jsp, andselectrename. Change this file name to viewallcatalogitemserror.jsp. 12.Looking at the relationship view in the Studio Workbench, you can see that this new page has taken the place of the old page. Unfortunately, this is a bit of a clumsy technique, but it is the best way to use the wizards. Repeat this process for every page in the ABCCompany project except for the StaticPages folder Restructuring directories Now that all the folders we are going to use have been put in to the project, we can restructure the project to be more friendly. 394 Web Enabling AS/400 Applications with IBM WebSphere Studio

405 The default page on our Web server is index.html. We should make this file available in the root of the file system. We also want the simple information pages available in the root directory. This will be the directory where we do not have to worry about security so we will keep low security files together. Complete these tasks: 1. In the Studio Workbench, go to the StaticPages folder, and select the Index.html file. 2. Drag this file to the root ABCCompany folder. 3. Repeat the first two steps for all the other files in the StaticPages folder. 4. Right-click the StaticPages folder, and select Delete. 5. Click the Yes option in the Confirmation dialog box Login page If we look at our Login page, we see that it is missing all the items that were on the Login page shown in 3.3.2, Constructing the Logon page on page 97. We will put these items back on this page so it fits the style of the current Web site. Follow this process: 1. Right-click the ABCCompany root directory, and select Insert->File. Fromthe Insert File dialog box, select the ABCCompanyTemplate.html file, and name it logincontent.html. 2. Double-click the logincontent.html file in the Studio Workbench. This checks the file out and opens it in the Page Designer. 3. We are just interested in the login table on this page. Select the content of the bottom right cell, and select Edit->Copy. 4. Go to the Studio Workbench, and double-click the file login.html. Thischecks it out and opens it in Page Designer. 5. Click in the middle right cell, and select Edit->Paste. Your page should look like the one in Figure 358 on page 396. Creating the complete ABC Company Web site 395

406 Figure 358. Page Designer: ABC Company Login page 6. Save this file, and exit from Page Designer. 7. In the Studio Workbench, right-click on the login.html file, and select Check In. 8. Right-click on the logincontent.html file, and select Delete. Make sure the Delete from disk option is selected, and click OK. 9. After the Login page is complete, copy the page into loginerror.html. Change the loginerror.html file to display an error message. If the login was invalid, the user will be redirected to the loginerror.html page, which functions exactly the same as the Login page and also displays error message The Welcome Registered User page The final page that needs to be created is the Welcome Registered User page. We do not know where the user intends to go on the Web site so we need to welcome them as a registered user. Follow these steps: 1. In the Studio Workbench, right-click on the ABCCompany root directory, and select Insert->File. 2. In the Insert File dialog box, select the template dyanmicpagetemplate.jsp. For the name, type loginindex.jsp, and click the OK button. 3. In the Studio Workbench, double-click loginindex.jsp. This checks out the file and opens it in Page Designer. 4. Double-click in the middle right cell, and set the Horizontal Alignment to Center. Then, click OK. 5. Press the Enter key twice, and then type Welcome. 6. Highlight the word Welcome, and select Format->Physical Emphasis ->Font. 7. For the font size attribute, select +2. Click the OK button. 396 Web Enabling AS/400 Applications with IBM WebSphere Studio

407 8. Press the Enter key twice, and then type some text thanking the user for returning to the Web site. Refer to Chapter 4, Restoring the ABC Company Web site sample project on page 121, for an example. 9. Save this file, and exit Page Designer Linking the Login page This procedure allows the user to register and login. Follow these steps: 1. In the Studio Workbench, double-click the login.html file. This checks out the file and opens it in Page Designer. 2. Double-click in the middle right cell in the form. You should get the Form Attribute dialog box. If you do not see this dialog box, click in the drop-down list box next to the Tag caption, and select Form. 3. Type /servlet/login for the action parameter, and set the method to Post. Click OK. 4. Double-click in the top field next to the caption called user ID. In the Attribute dialog box, type username for the Name. Click OK. 5. Double-click in the bottom field next to the caption called password. Inthe Attribute dialog box, type password. Click the OK button. 6. Save this file, and exit Page Designer Linking the Registered User pages together We now have all the pages formatted for either the registered user area or the general browsable area. We now need to link all the pages together. We use this process: 1. In the Studio Workbench, double-click on the viewallcatalogitemsinput.html file. This checks out the file and opens it in Page Designer. The page should look like the example in Figure 359. Figure 359. Page Designer: viewallcatalogitemsinput.html for initial parameters Creating the complete ABC Company Web site 397

IBM WebSphere Application Server V3.5, Advanced Edition Expands Platform Support and Leverages the Performance of the Java 2 Software Development Kit

IBM WebSphere Application Server V3.5, Advanced Edition Expands Platform Support and Leverages the Performance of the Java 2 Software Development Kit Software Announcement July 25, 2000 IBM V3.5, Expands Platform Support and Leverages the Performance of the Java 2 Software Development Kit Overview WebSphere Application Server V3.5, manages and integrates

More information

IBM WebSphere Application Server V3.5, Advanced Edition for Linux Extends Support to Red Hat, Caldera, SuSE, and TurboLinux

IBM WebSphere Application Server V3.5, Advanced Edition for Linux Extends Support to Red Hat, Caldera, SuSE, and TurboLinux Software Announcement December 5, 2000 IBM Server V3.5, Advanced Extends Support to Red Hat, Caldera, SuSE, and TurboLinux Overview WebSphere Application Edition for Linux manages and integrates enterprise-wide

More information

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: WSAD. J2EE business topologies. Workbench. Project. Workbench components. Java development tools. Java projects

More information

IBM WebSphere Commerce Suite

IBM WebSphere Commerce Suite Tools to build dynamic e-commerce solutions IBM WebSphere Commerce Suite Tools HTML authoring Catalog management Site development Rules development Merchandising Administration Customers expect fast, reliable,

More information

National Language Support for Windows NT and AIX Now Available with IBM WebSphere Application Server V3.0.1, Standard Edition

National Language Support for Windows NT and AIX Now Available with IBM WebSphere Application Server V3.0.1, Standard Edition Software Announcement November 16, 1999 National Language Support for Windows NT and AIX Now Available with IBM WebSphere Application Server V3.0.1, Standard Edition Overview WebSphere Application Server

More information

Extended Search Administration

Extended Search Administration IBM Lotus Extended Search Extended Search Administration Version 4 Release 0.1 SC27-1404-02 IBM Lotus Extended Search Extended Search Administration Version 4 Release 0.1 SC27-1404-02 Note! Before using

More information

Lotus esuite Workplace for IBM Network Station Manager for AS/400 Date: December 8, 1998

Lotus esuite Workplace for IBM Network Station Manager for AS/400 Date: December 8, 1998 Lotus esuite Workplace for IBM Network Station Manager for AS/400 Date: December 8, 1998 TABLE OF CONTENTS ----------------- ----------------- -Prerequisites -Installation -Migration -Auto-configuration

More information

Integration Developer Version 7.0 Version 7.0. Installation Guide

Integration Developer Version 7.0 Version 7.0. Installation Guide Integration Developer Version 7.0 Version 7.0 Installation Guide Note Before using this information and the product it supports, be sure to read the general information under Notices on page 67. This edition

More information

IBM WebSphere Application Server - Express, Version 5.1

IBM WebSphere Application Server - Express, Version 5.1 An express entry point to dynamic e-business IBM Express, Version 5.1 Highlights Offers a quick and affordable solution to develop, deploy and manage e-business applications Speeds application development

More information

The team that wrote this redbook

The team that wrote this redbook Preface p. xix The team that wrote this redbook p. xix Comments welcome p. xxiii Overview of WebSphere Application Server V3.5 p. 1 What is WebSphere Application Server? p. 1 WebSphere Application Server

More information

IBM SecureWay On-Demand Server Version 2.0

IBM SecureWay On-Demand Server Version 2.0 Securely delivering personalized Web applications IBM On-Demand Server Version 2.0 Highlights Delivers personalized Web solutions on demand to anyone, anywhere using profile serving Provides industry-leading,

More information

IBM Content Manager OnDemand for i5/os Common Server Planning and Installation Guide

IBM Content Manager OnDemand for i5/os Common Server Planning and Installation Guide System i IBM Content Manager OnDemand for i5/os Common Server Planning and Installation Guide Version 6 Release 1 SC27-1158-04 System i IBM Content Manager OnDemand for i5/os Common Server Planning and

More information

BEA WebLogic Server Integration Guide

BEA WebLogic Server Integration Guide IBM Tivoli Access Manager for e-business BEA WebLogic Server Integration Guide Version 5.1 SC32-1366-00 IBM Tivoli Access Manager for e-business BEA WebLogic Server Integration Guide Version 5.1 SC32-1366-00

More information

IBM System i Web Enablement made easy

IBM System i Web Enablement made easy Software Announcement October 10, 2006 IBM System i Web Enablement made easy Overview Web Enablement for i5/os (5722-WE2) Web Enablement is enhanced to include Express Runtime Web Environments, which can

More information

WebLearning IBM Curriculum

WebLearning IBM Curriculum WebLearning IBM Curriculum WebSphere Commerce Suite Marketplace Edition Implementation Table of Contents: Overview Who Should Take This Course What You Are Taught Topics Include Prerequisites Duration:

More information

Installing and Administering a Satellite Environment

Installing and Administering a Satellite Environment IBM DB2 Universal Database Installing and Administering a Satellite Environment Version 8 GC09-4823-00 IBM DB2 Universal Database Installing and Administering a Satellite Environment Version 8 GC09-4823-00

More information

xiii A. Hayden Lindsey IBM Distinguished Engineer and Director, Studio Tools Foreword

xiii A. Hayden Lindsey IBM Distinguished Engineer and Director, Studio Tools Foreword Foreword Business applications are increasingly leveraging Web technologies. Naturally this is true for Internet applications, but it is also true for intranet and extranet applications applications that

More information

Introduction and Planning Guide

Introduction and Planning Guide Content Manager OnDemand for Multiplatforms Introduction and Planning Guide Version 7.1 GC27-0839-00 Content Manager OnDemand for Multiplatforms Introduction and Planning Guide Version 7.1 GC27-0839-00

More information

IBM WebSphere Development Studio for IBM iseries V5R1 and V5R2 Refreshed with New WebSphere Studio, V5.0 Workstation Tools

IBM WebSphere Development Studio for IBM iseries V5R1 and V5R2 Refreshed with New WebSphere Studio, V5.0 Workstation Tools Software Announcement January 28, 2003 IBM WebSphere Development Studio for IBM iseries V5R1 and V5R2 Refreshed with New WebSphere Studio, V5.0 Workstation Tools Overview WebSphere Development Studio for

More information

IBM Tivoli Federated Identity Manager Version Installation Guide GC

IBM Tivoli Federated Identity Manager Version Installation Guide GC IBM Tivoli Federated Identity Manager Version 6.2.2 Installation Guide GC27-2718-01 IBM Tivoli Federated Identity Manager Version 6.2.2 Installation Guide GC27-2718-01 Note Before using this information

More information

Connecting to System i System i Access for Web

Connecting to System i System i Access for Web System i Connecting to System i System i Access for Web Version 6 Release 1 System i Connecting to System i System i Access for Web Version 6 Release 1 Note Before using this information and the product

More information

WebFacing Applications with. Leonardo LLames IBM Advanced Technical Support Rochester, MN. Copyright IBM 2002 ebusinessforu Pages 1

WebFacing Applications with. Leonardo LLames IBM Advanced Technical Support Rochester, MN. Copyright IBM 2002 ebusinessforu Pages 1 WebFacing 5250 Applications with Leonardo LLames IBM Advanced Technical Support Rochester, MN Copyright IBM 2002 ebusinessforu Pages 1 Disclaimer Acknowledgement: This presentation is a collaborative effort

More information

Web-enable a 5250 application with the IBM WebFacing Tool

Web-enable a 5250 application with the IBM WebFacing Tool Web-enable a 5250 application with the IBM WebFacing Tool ii Web-enable a 5250 application with the IBM WebFacing Tool Contents Web-enable a 5250 application using the IBM WebFacing Tool......... 1 Introduction..............1

More information

User-to-Business Patterns for e-business

User-to-Business Patterns for e-business User-to-Business Patterns for e-business Developing AS/400e e-business Applications Learn AS/400e e-business application programming techniques Develop, test applications with WebSphere Studio, VisualAge

More information

Chapter 2 FEATURES AND FACILITIES. SYS-ED/ Computer Education Techniques, Inc.

Chapter 2 FEATURES AND FACILITIES. SYS-ED/ Computer Education Techniques, Inc. Chapter 2 FEATURES AND FACILITIES SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: JDeveloper features. Java in the database. Simplified database access. IDE: Integrated Development

More information

Version Monitoring Agent User s Guide SC

Version Monitoring Agent User s Guide SC Tivoli IBM Tivoli Advanced Catalog Management for z/os Version 02.01.00 Monitoring Agent User s Guide SC23-7974-00 Tivoli IBM Tivoli Advanced Catalog Management for z/os Version 02.01.00 Monitoring Agent

More information

Developing Java TM 2 Platform, Enterprise Edition (J2EE TM ) Compatible Applications Roles-based Training for Rapid Implementation

Developing Java TM 2 Platform, Enterprise Edition (J2EE TM ) Compatible Applications Roles-based Training for Rapid Implementation Developing Java TM 2 Platform, Enterprise Edition (J2EE TM ) Compatible Applications Roles-based Training for Rapid Implementation By the Sun Educational Services Java Technology Team January, 2001 Copyright

More information

IBM Tivoli Monitoring for Web Infrastructure: WebSphere Application Server. User s Guide. Version SC

IBM Tivoli Monitoring for Web Infrastructure: WebSphere Application Server. User s Guide. Version SC IBM Tivoli Monitoring for Web Infrastructure: WebSphere Application Server User s Guide Version 5.1.1 SC23-4705-01 IBM Tivoli Monitoring for Web Infrastructure: WebSphere Application Server User s Guide

More information

Lotus Learning Management System R1

Lotus Learning Management System R1 Lotus Learning Management System R1 Version 1.0.4 March 2004 Administrator's Guide G210-1785-00 Contents Chapter 1 Introduction to the Learning Management System and Administration...1 Understanding the

More information

WA2031 WebSphere Application Server 8.0 Administration on Windows. Student Labs. Web Age Solutions Inc. Copyright 2012 Web Age Solutions Inc.

WA2031 WebSphere Application Server 8.0 Administration on Windows. Student Labs. Web Age Solutions Inc. Copyright 2012 Web Age Solutions Inc. WA2031 WebSphere Application Server 8.0 Administration on Windows Student Labs Web Age Solutions Inc. Copyright 2012 Web Age Solutions Inc. 1 Table of Contents Directory Paths Used in Labs...3 Lab Notes...4

More information

iseries & WebSphere Express

iseries & WebSphere Express IBM eserverj iseriesj iseries & WebSphere Express Peter Eibak Nordic iseries Solution Specialist IBM Danmark A/S Nymøllevej 85 2800 Lyngby Denmark Tel +45 45 23 43 11 (Office) Tel +45 28 80 43 11 (Cell)

More information

IBM WebSphere Host Access Transformation Services, Version 7.0

IBM WebSphere Host Access Transformation Services, Version 7.0 Reface and reuse your host assets IBM WebSphere Host Access Transformation Services, Version 7.0 Highlights Enhances 3270 and 5250 screens Combines data from multiple with a GUI host screens with a new

More information

Rational Systems Developer

Rational Systems Developer Rational Systems Developer Version 7.0 Installation Guide GI11-8355-04 Rational Systems Developer Version 7.0 Installation Guide GI11-8355-04 Note Before using this information and the product it supports,

More information

BEAWebLogic. Portal. Overview

BEAWebLogic. Portal. Overview BEAWebLogic Portal Overview Version 10.2 Revised: February 2008 Contents About the BEA WebLogic Portal Documentation Introduction to WebLogic Portal Portal Concepts.........................................................2-2

More information

Upgrading from Call Center Reporting to Reporting for Call Center

Upgrading from Call Center Reporting to Reporting for Call Center Upgrading from Call Center Reporting to Reporting for Call Center www.nortelnetworks.com 2003 Nortel Networks i Table of Contents Table of Contents Change History...1 How to use this guide...2 Introduction...

More information

Distributed Multitiered Application

Distributed Multitiered Application Distributed Multitiered Application Java EE platform uses a distributed multitiered application model for enterprise applications. Logic is divided into components https://docs.oracle.com/javaee/7/tutorial/overview004.htm

More information

Client Installation and User's Guide

Client Installation and User's Guide IBM Tivoli Storage Manager FastBack for Workstations 6.1.2.0 Client Installation and User's Guide SC27-2809-01 IBM Tivoli Storage Manager FastBack for Workstations 6.1.2.0 Client Installation and User's

More information

Upgrading from Call Center Reporting to

Upgrading from Call Center Reporting to Upgrading from Call Center Reporting to Reporting for Call Center Upgrade Document Reporting for Call Center Release 2.2.1xx Document Number: 200-0400-110 Document Status: Standard Document Version: 3.02

More information

Client Installation and User's Guide

Client Installation and User's Guide IBM Tivoli Storage Manager FastBack for Workstations Version 7.1 Client Installation and User's Guide SC27-2809-03 IBM Tivoli Storage Manager FastBack for Workstations Version 7.1 Client Installation

More information

EVALUATION ONLY. WA2097 WebSphere Application Server 8.5 Administration on Linux. Student Labs. Web Age Solutions Inc.

EVALUATION ONLY. WA2097 WebSphere Application Server 8.5 Administration on Linux. Student Labs. Web Age Solutions Inc. WA2097 WebSphere Application Server 8.5 Administration on Linux Student Labs Web Age Solutions Inc. Copyright 2013 Web Age Solutions Inc. 1 Table of Contents Directory Paths Used in Labs...3 Lab Notes...4

More information

Server for IBM i. Dawn May Presentation created by Tim Rowe, 2008 IBM Corporation

Server for IBM i. Dawn May Presentation created by Tim Rowe, 2008 IBM Corporation Integrated Web Application Server for IBM i Dawn May dmmay@us.ibm.com Presentation created by Tim Rowe, timmr@us.ibm.com IBM i integrated Web application server the on-ramp to the Web 2 Agenda Integrated

More information

IBM WebSphere Application Server Version 4.0, Advanced Single Server Edition for iseries

IBM WebSphere Application Server Version 4.0, Advanced Single Server Edition for iseries Software Announcement August 14, 2001 IBM WebSphere Application Server Version 4.0, Advanced Single Server Edition for iseries Overview IBM Advanced Single Server Edition for iseries is a lower total cost

More information

IBM WebSphere Studio Asset Analyzer, Version 5.1

IBM WebSphere Studio Asset Analyzer, Version 5.1 Helping you quickly understand, enhance and maintain enterprise applications IBM, Version 5.1 Highlights n Provides interactive textual n Helps shorten the learning curve and graphic reports that help

More information

IBM WebSphere Commerce Suite

IBM WebSphere Commerce Suite Tools to build a powerful e-commerce site IBM WebSphere Commerce Suite Highlights Helps get e-commerce sites up and running quickly through a store creation wizard and teambased Web development tools Provides

More information

Enterprise Java Unit 1-Chapter 2 Prof. Sujata Rizal Java EE 6 Architecture, Server and Containers

Enterprise Java Unit 1-Chapter 2 Prof. Sujata Rizal Java EE 6 Architecture, Server and Containers 1. Introduction Applications are developed to support their business operations. They take data as input; process the data based on business rules and provides data or information as output. Based on this,

More information

IBM z/os Management Facility V2R1 Solution Guide IBM Redbooks Solution Guide

IBM z/os Management Facility V2R1 Solution Guide IBM Redbooks Solution Guide IBM z/os Management Facility V2R1 Solution Guide IBM Redbooks Solution Guide z/osmf is a product for IBM z/os that simplifies, optimizes, and modernizes the z/os system programmer experience. z/osmf delivers

More information

Exam Name: IBM Certified System Administrator - WebSphere Application Server Network Deployment V7.0

Exam Name: IBM Certified System Administrator - WebSphere Application Server Network Deployment V7.0 Vendor: IBM Exam Code: 000-377 Exam Name: IBM Certified System Administrator - WebSphere Application Server Network Deployment V7.0 Version: Demo QUESTION 1 An administrator would like to use the Centralized

More information

Developer Marketing: Build a Web Server Using Microsoft IIS 4.0 CBT Skill Builder Courseware

Developer Marketing: Build a Web Server Using Microsoft IIS 4.0 CBT Skill Builder Courseware Software Announcement April 10, 2001 Developer Marketing: Build a Web Server Using Microsoft IIS 4.0 CBT Skill Builder Courseware Overview Build your skills for Microsoft Certified Systems Engineer (MCSE)

More information

Business Intelligence Tutorial

Business Intelligence Tutorial IBM DB2 Universal Database Business Intelligence Tutorial Version 7 IBM DB2 Universal Database Business Intelligence Tutorial Version 7 Before using this information and the product it supports, be sure

More information

Rational Application Developer 7 Bootcamp

Rational Application Developer 7 Bootcamp Rational Application Developer 7 Bootcamp Length: 1 week Description: This course is an intensive weeklong course on developing Java and J2EE applications using Rational Application Developer. It covers

More information

Tivoli Management Solution for Domino. Installation and Setup Guide. Version GC

Tivoli Management Solution for Domino. Installation and Setup Guide. Version GC Tivoli Management Solution for Domino Installation and Setup Guide Version 3.2.0 GC32-0755-00 Tivoli Management Solution for Domino Installation and Setup Guide Version 3.2.0 GC32-0755-00 Tivoli Management

More information

Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve

Introduction. Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve Enterprise Java Introduction Enterprise Java Instructor: Please introduce yourself Name Experience in Java Enterprise Edition Goals you hope to achieve Course Description This course focuses on developing

More information

WebSphere Performance

WebSphere Performance IBM WEBSPHERE WORKSHOP - LAB EXERCISE WebSphere 4.0 - Performance What This Exercise is About In this exercise you will look at some of the new performance features and tools available in WebSphere 4.0.

More information

SAS Model Manager 2.3

SAS Model Manager 2.3 SAS Model Manager 2.3 Administrator's Guide SAS Documentation The correct bibliographic citation for this manual is as follows: SAS Institute Inc. 2010. SAS Model Manager 2.3: Administrator's Guide. Cary,

More information

Tivoli Inventory 4.0 Provides A Cross-Platform Automated Solution For Inventory Management

Tivoli Inventory 4.0 Provides A Cross-Platform Automated Solution For Inventory Management Software Announcement May 1, 2001 Tivoli Inventory 4.0 Provides A Cross-Platform Automated Solution For Inventory Management Overview Challenged by the need to efficiently maintain accurate IT asset information

More information

IBM. Planning and Installation. IBM Tivoli Workload Scheduler. Version 9 Release 1 SC

IBM. Planning and Installation. IBM Tivoli Workload Scheduler. Version 9 Release 1 SC IBM Tivoli Workload Scheduler IBM Planning and Installation Version 9 Release 1 SC32-1273-13 IBM Tivoli Workload Scheduler IBM Planning and Installation Version 9 Release 1 SC32-1273-13 Note Before using

More information

IBM QMF for Windows for IBM iseries, V7.2 Business Intelligence Starts Here!

IBM QMF for Windows for IBM iseries, V7.2 Business Intelligence Starts Here! Software Announcement February 26, 2002 IBM QMF for Windows for IBM iseries, V7.2 Business Intelligence Starts Here! Overview QMF for Windows for iseries, V7.2, is a multipurpose enterprise query environment

More information

Rational Software Architect

Rational Software Architect Rational Software Architect Version 7.0 Installation Guide GI11-8354-04 Rational Software Architect Version 7.0 Installation Guide GI11-8354-04 Note Before using this information and the product it supports,

More information

Tutorial: Maintaining an ILE COBOL application: Introducing a new level of server tool integration for iseries application development

Tutorial: Maintaining an ILE COBOL application: Introducing a new level of server tool integration for iseries application development Page 1 of 165 Tutorial: Maintaining an ILE COBOL application: Introducing a new level of server tool integration for iseries application development About the tutorial This tutorial through a series of

More information

Using the VisualAge for Java WebSphere Test Environment

Using the VisualAge for Java WebSphere Test Environment Using the VisualAge for Java WebSphere Test Environment By Craig Pelkie Many iseries 400 shops are starting to move their development efforts to web enablement using WebSphere Application Server (WAS).

More information

software Learning Management System R1

software Learning Management System R1 software Learning Management System R1 Administrator's Guide December 2003 Disclaimer THE INFORMATION CONTAINED IN THIS DOCUMENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILE EFFORTS WERE MADE

More information

DEPLOYMENT GUIDE DEPLOYING F5 WITH ORACLE ACCESS MANAGER

DEPLOYMENT GUIDE DEPLOYING F5 WITH ORACLE ACCESS MANAGER DEPLOYMENT GUIDE DEPLOYING F5 WITH ORACLE ACCESS MANAGER Table of Contents Table of Contents Introducing the F5 and Oracle Access Manager configuration Prerequisites and configuration notes... 1 Configuration

More information

Web Enablement Kit Implementation Guide

Web Enablement Kit Implementation Guide Content Manager OnDemand for Multiplatforms Version 8 Release 5 Web Enablement Kit Implementation Guide SC19-2941-00 Content Manager OnDemand for Multiplatforms Version 8 Release 5 Web Enablement Kit

More information

DISCLAIMER COPYRIGHT List of Trademarks

DISCLAIMER COPYRIGHT List of Trademarks DISCLAIMER This documentation is provided for reference purposes only. While efforts were made to verify the completeness and accuracy of the information contained in this documentation, this documentation

More information

Client Installation and User's Guide

Client Installation and User's Guide IBM Tivoli Storage Manager FastBack for Workstations Version 7.1.1 Client Installation and User's Guide SC27-2809-04 IBM Tivoli Storage Manager FastBack for Workstations Version 7.1.1 Client Installation

More information

Workplace Designer. Installation and Upgrade Guide. Version 2.6 G

Workplace Designer. Installation and Upgrade Guide. Version 2.6 G Workplace Designer Version 2.6 for Windows, Linux, AIX, Solaris, iseries Installation and Upgrade Guide G210-2219-01 Note Before using this information and the product it supports, read the information

More information

DB2 Content Manager Enterprise Edition DB2 Content Manager for z/os Version DB2 Content Manager Readme

DB2 Content Manager Enterprise Edition DB2 Content Manager for z/os Version DB2 Content Manager Readme DB2 Content Manager Enterprise Edition DB2 Content Manager for z/os Version 8.4.2 DB2 Content Manager Readme DB2 Content Manager Enterprise Edition DB2 Content Manager for z/os Version 8.4.2 DB2 Content

More information

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc. Chapter 1 GETTING STARTED SYS-ED/ Computer Education Techniques, Inc. Objectives You will learn: The IDE: Integrated Development Environment. MVC: Model-View-Controller Architecture. BC4J: Business Components

More information

Central Administration Console Installation and User's Guide

Central Administration Console Installation and User's Guide IBM Tivoli Storage Manager FastBack for Workstations Version 7.1 Central Administration Console Installation and User's Guide SC27-2808-03 IBM Tivoli Storage Manager FastBack for Workstations Version

More information

IBM Application Runtime Expert for i

IBM Application Runtime Expert for i IBM Application Runtime Expert for i Tim Rowe timmr@us.ibm.com Problem Application not working/starting How do you check everything that can affect your application? Backup File Owner & file size User

More information

TOPLink for WebLogic. Whitepaper. The Challenge: The Solution:

TOPLink for WebLogic. Whitepaper. The Challenge: The Solution: Whitepaper The Challenge: Enterprise JavaBeans (EJB) represents a new standard in enterprise computing: a component-based architecture for developing and deploying distributed object-oriented applications

More information

DB2 for z/os: Programmer Essentials for Designing, Building and Tuning

DB2 for z/os: Programmer Essentials for Designing, Building and Tuning Brett Elam bjelam@us.ibm.com - DB2 for z/os: Programmer Essentials for Designing, Building and Tuning April 4, 2013 DB2 for z/os: Programmer Essentials for Designing, Building and Tuning Information Management

More information

Micro Focus Net Express

Micro Focus Net Express data sheet Micro Focus Net Express Micro Focus Net Express provides a complete environment for quickly building and modernizing COBOL enterprise components and business applications for client/server platforms

More information

X-S Framework Leveraging XML on Servlet Technology

X-S Framework Leveraging XML on Servlet Technology X-S Framework Leveraging XML on Servlet Technology Rajesh Kumar R Abstract This paper talks about a XML based web application framework that is based on Java Servlet Technology. This framework leverages

More information

IBM DB2 Query Patroller. Administration Guide. Version 7 SC

IBM DB2 Query Patroller. Administration Guide. Version 7 SC IBM DB2 Query Patroller Administration Guide Version 7 SC09-2958-00 IBM DB2 Query Patroller Administration Guide Version 7 SC09-2958-00 Before using this information and the product it supports, be sure

More information

AD105 Introduction to Application Development for the IBM Workplace Managed Client

AD105 Introduction to Application Development for the IBM Workplace Managed Client AD105 Introduction to Application Development for the IBM Workplace Managed Client Rama Annavajhala, IBM Workplace Software, IBM Software Group Sesha Baratham, IBM Workplace Software, IBM Software Group

More information

IBM Decision Server Insights. Installation Guide. Version 8 Release 6

IBM Decision Server Insights. Installation Guide. Version 8 Release 6 IBM Decision Server Insights Installation Guide Version 8 Release 6 IBM Decision Server Insights Installation Guide Version 8 Release 6 Note Before using this information and the product it supports,

More information

Getting Started in the World of WebSphere; Real World Case Studies

Getting Started in the World of WebSphere; Real World Case Studies s Getting Started in the World of WebSphere; Real World Case Studies Paul Holm PlanetJ Corporation Pholm@planetjavainc.com 2005 PlanetJ Corporation. All rights reserved. What We'll Cover... How are Java

More information

Managing Domino/Notes with Tivoli Manager for Domino, Enterprise Edition, Version 1.5

Managing Domino/Notes with Tivoli Manager for Domino, Enterprise Edition, Version 1.5 Managing Domino/Notes with Tivoli Manager for Domino, Enterprise Edition, Version 1.5 Kathy Hebblethwaite, Massimo Borzani, Raine Haapasaari, Sari Haapasaari International Technical Support Organization

More information

Oracle WebLogic Server 11g: Administration Essentials

Oracle WebLogic Server 11g: Administration Essentials Oracle University Contact Us: +33 (0) 1 57 60 20 81 Oracle WebLogic Server 11g: Administration Essentials Duration: 5 Days What you will learn This Oracle WebLogic Server 11g: Administration Essentials

More information

Orgnazition of This Part

Orgnazition of This Part Orgnazition of This Part Table of Contents Tutorial: Organization of This Part...1 Lesson 1: Starting JReport Enterprise Server and Viewing Reports...3 Introduction...3 Installing JReport Enterprise Server...3

More information

IBM MQSeries Integrator Agent for CICS Transaction Server Enables MDp Customers to Move to Business Integration

IBM MQSeries Integrator Agent for CICS Transaction Server Enables MDp Customers to Move to Business Integration Software Announcement March 13, 2001 IBM MQSeries Integrator Agent for CICS Transaction Server Enables MDp Customers to Move to Business Integration Overview The MQSeries Integrator Agent for CICS Transaction

More information

Appeon Installation Guide for WebSphere

Appeon Installation Guide for WebSphere Appeon Installation Guide for WebSphere Appeon 6.5 for PowerBuilder WINDOWS DOCUMENT ID: DC00809-01-0650-01 LAST REVISED: November 2010 Copyright 2010 by Appeon Corporation. All rights reserved. This publication

More information

HYPERION SYSTEM 9 BI+ GETTING STARTED GUIDE APPLICATION BUILDER J2EE RELEASE 9.2

HYPERION SYSTEM 9 BI+ GETTING STARTED GUIDE APPLICATION BUILDER J2EE RELEASE 9.2 HYPERION SYSTEM 9 BI+ APPLICATION BUILDER J2EE RELEASE 9.2 GETTING STARTED GUIDE Copyright 1998-2006 Hyperion Solutions Corporation. All rights reserved. Hyperion, the Hyperion H logo, and Hyperion s product

More information

A General ecommerce Platform with Strong International and Local Aspects

A General ecommerce Platform with Strong International and Local Aspects A General ecommerce Platform with Strong International and Local Aspects By Martin Ramsin A Master s Thesis August 2000 Examiner: Professor Seif Haridi Supervisors:Andy Neil and Mark Bünger, Icon MediaLab

More information

Error Message Reference

Error Message Reference Security Policy Manager Version 7.1 Error Message Reference GC23-9477-01 Security Policy Manager Version 7.1 Error Message Reference GC23-9477-01 Note Before using this information and the product it

More information

software Learning Management System R1

software Learning Management System R1 software Learning Management System R1 Administrator's Guide September 2003 Disclaimer THE INFORMATION CONTAINED IN THIS DOCUMENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY. WHILE EFFORTS WERE MADE

More information

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1

Vision of J2EE. Why J2EE? Need for. J2EE Suite. J2EE Based Distributed Application Architecture Overview. Umair Javed 1 Umair Javed 2004 J2EE Based Distributed Application Architecture Overview Lecture - 2 Distributed Software Systems Development Why J2EE? Vision of J2EE An open standard Umbrella for anything Java-related

More information

Nimsoft Monitor. websphere Guide. v1.5 series

Nimsoft Monitor. websphere Guide. v1.5 series Nimsoft Monitor websphere Guide v1.5 series Legal Notices Copyright 2012, Nimsoft Corporation Warranty The material contained in this document is provided "as is," and is subject to being changed, without

More information

Universal Manageability: Enterprise Management Integration

Universal Manageability: Enterprise Management Integration Universal Manageability: Enterprise Management Integration Barry Nusbaum, Cesar Augusto Coelho Ripari International Technical Support Organization www.redbooks.ibm.com SG24-5388-00 International Technical

More information

Tivoli Monitoring Agent for IBM Tivoli Monitoring 5.x Endpoint

Tivoli Monitoring Agent for IBM Tivoli Monitoring 5.x Endpoint Tivoli Monitoring Agent for IBM Tivoli Monitoring 5.x Endpoint Version 6.1.0 User s Guide SC32-9490-00 Tivoli Monitoring Agent for IBM Tivoli Monitoring 5.x Endpoint Version 6.1.0 User s Guide SC32-9490-00

More information

Introducing Lotus Domino 8, Designer 8 and Composite Applications

Introducing Lotus Domino 8, Designer 8 and Composite Applications Introducing Lotus Domino 8, Designer 8 and Composite Applications IBM Lotus collaboration product strategy Rich client W indows/office Browser eforms Portal RSS/Atom Mobile Interaction and client services

More information

Exchange 2000 Agent Installation Guide

Exchange 2000 Agent Installation Guide IBM Tivoli Identity Manager Exchange 2000 Agent Installation Guide Version 4.5.0 SC32-1156-03 IBM Tivoli Identity Manager Exchange 2000 Agent Installation Guide Version 4.5.0 SC32-1156-03 Note: Before

More information

Relativity Designer Installation Guide

Relativity Designer Installation Guide Liant Software Corporation Relativity Designer Installation Guide Version 5 Copyright 1994-2003 by Liant Software Corporation. All rights reserved. Printed in U.S.A. No part of this publication may be

More information

Installing IPM on Windows

Installing IPM on Windows CHAPTER 5 This chapter describes how to install the IPM server software on Windows NT, Windows 2000 Professional, or Windows 2000 Server system, and how to install the IPM client software on a Windows

More information

JReport Enterprise Server Getting Started

JReport Enterprise Server Getting Started JReport Enterprise Server Getting Started Table of Contents Getting Started: Organization of This Part...1 First Step...3 What You Should Already Know...3 Target Customers...3 Where to Find More Information

More information

Application Servers - Installing SAP Web Application Server

Application Servers - Installing SAP Web Application Server Proven Practice Application Servers - Installing SAP Web Application Server Product(s): IBM Cognos 8.3, SAP Web Application Server Area of Interest: Infrastructure DOC ID: AS02 Version 8.3.0.0 Installing

More information

Deployment Scenario: WebSphere Portal Mashup integration and page builder

Deployment Scenario: WebSphere Portal Mashup integration and page builder Deployment Scenario: WebSphere Portal 6.1.5 Mashup integration and page builder Deployment Scenario: WebSphere Portal 6.1.5 Mashup integration and page builder...1 Abstract...2 Portal Mashup integration

More information

Policy Manager for IBM WebSphere DataPower 7.2: Configuration Guide

Policy Manager for IBM WebSphere DataPower 7.2: Configuration Guide Policy Manager for IBM WebSphere DataPower 7.2: Configuration Guide Policy Manager for IBM WebSphere DataPower Configuration Guide SOAPMDP_Config_7.2.0 Copyright Copyright 2015 SOA Software, Inc. All rights

More information

Virtual Loaner Program setup guide for the IBM Industry Application Platform Version 1.0.1

Virtual Loaner Program setup guide for the IBM Industry Application Platform Version 1.0.1 Virtual Loaner Program setup guide for the IBM Industry Application Platform Version 1.0.1 David Carew IT Architect, IBM Corporation IBM Systems ISV Business Strategy November 2010 Copyright IBM Corporation,

More information