You are on page 1of 250

Creating an Interactive

B2B Web Application


Access diverse resources using
connectors

Perform transactions across


Business Partners

Exchange data among


servlets

Deborah Cottingham
Denis Gaebler

ibm.com/redbooks
SG24-6221-00

International Technical Support Organization

Creating an Interactive B2B Web Application

May 2001
Take Note!
Before using this information and the product it supports, be sure to read the general information in
Appendix C, “Special notices” on page 209.

First Edition (May 2001)

This edition applies to WebSphere Application Server for OS/390 Version 3.02 Service Level 3,
VisualAge for Java Version 3.02 for Windows NT, and WebSphere Studio Version 3.5 for Windows NT.

Comments may be addressed to:


IBM Corporation, International Technical Support Organization
Dept. 5KNA Building 80-E2
650 Harry Road
San Jose, California 95120-6099

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 2001. 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.
Contents

Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix

Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii

Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
The team that wrote this redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Comments welcome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii

Part 1. Overview of the scenario . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 1. Introduction . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . .3
1.1 Scenario overview . . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . .3
1.1.1 S/390 software prerequisites . . . . . . . . . . .. . . . .. . . . . .. . . . . .4
1.1.2 Windows NT client software prerequisites .. . . . .. . . . . .. . . . . .5
1.2 Overview of the servlets . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . .5
1.2.1 Order servlet . . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . .6
1.2.2 Bid servlet . . . . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . .7
1.2.3 Accept servlet. . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . .9
1.2.4 Email servlet. . . . . . . . . . . . . . . . . . . . . . . .. . . . .. . . . . .. . . . . 11
1.3 Overview of the server environment . . . . . . . . . .. . . . .. . . . . .. . . . . 12
1.4 Overview of the Web application . . . . . . . . . . . .. . . . .. . . . . .. . . . . 13
1.4.1 From the user’s perspective . . . . . . . . . . . .. . . . .. . . . . .. . . . . 13
1.4.2 From the programmer’s perspective . . . . . .. . . . .. . . . . .. . . . . 17

Chapter 2. Install the development software . . . . . . . . . . . . . . . . . . . . 19


2.1 Install IBM VisualAge for Java V3.02 . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.2 Install VisualAge for Java features . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.3 Install IBM WebSphere Studio 3.5 . . . . . . . . . . . . . . . . . . . . . . . . . . . 20
2.4 Install a Web browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.5 Install the demo files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

Chapter 3. About the server configuration . . . . . . . . . . .. . . . . .. . . . . 23


3.1 About the application flow . . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . 23
3.1.1 Getting started . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . 25
3.1.2 Retrieving customer order information . . . . . . . . .. . . . . .. . . . . 27
3.1.3 Requesting shipping options . . . . . . . . . . . . . . . . .. . . . . .. . . . . 29
3.1.4 Accepting a bid . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . 31
3.1.5 Emailing the customer . . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . 33
3.2 About the server applications . . . . . . . . . . . . . . . . . . . .. . . . . .. . . . . 34
3.2.1 About the customer and order applications . . . . . .. . . . . .. . . . . 34

© Copyright IBM Corp. 2001 iii


3.2.2 About the shipper applications . . . . . . . . . . . . . . . . . . . . . . . . . . 35
3.2.3 About the hub application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
3.2.4 About the IMS customer application . . . . . . . . . . . . . . . . . . . . . . 36
3.2.5 Check database and transaction. . . . . . . . . . . . . . . . . . . . . . . . . 38
3.3 About the subsystem configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3.1 About MQSeries configuration . . . . . . . . . . . . . . . . . . . . . . . . . . 39
3.3.2 About MQ/CICS Bridge configuration . . . . . . . . . . . . . . . . . . . . . 39
3.3.3 About CICS configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3.4 About DB2 configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
3.3.5 About WebSphere Application Server configuration . . . . . . . . . . 41
3.3.6 About IMS Connect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 43

Part 2. Creating the servlets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 45

Chapter 4. Create the order servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47


4.1 Create Java beans that access CICS and DB2 . . . . . . . . . . . . . . . . . . 47
4.1.1 Create the B2BApp project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.2 Create the order package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 48
4.1.3 Create the COBOL customer record type . . . . . . . . . . . . . . . . . . 48
4.1.4 Create the CustomerRecord class . . . . . . . . . . . . . . . . . . . . . . . 49
4.1.5 Create the COBOL order record type . . . . . . . . . . . . . . . . . . . . . 50
4.1.6 Create the OrderRecord class . . . . . . . . . . . . . . . . . . . . . . . . . . 50
4.1.7 Create the RetrieveCustomerCommand class . . . . . . . . . . . . . . 51
4.1.8 Create the RetrieveOrderCommand class . . . . . . . . . . . . . . . . . 57
4.1.9 Create the CICSRetrieveNavigator class . . . . . . . . . . . . . . . . . . 60
4.2 Test the CICS connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
4.2.1 Create a CICSNavExecute test application . . . . . . . . . . . . . . . . . 67
4.2.2 Run the CICSNavExecute test . . . . . . . . . . . . . . . . . . . . . . . . . . 69
4.2.3 What you have proved so far . . . . . . . . . . . . . . . . . . . . . . . . . . . 70
4.2.4 Create a version of the order package . . . . . . . . . . . . . . . . . . . . 71
4.3 Generate the order servlet and generic user interface files . . . . . . . . . 71
4.3.1 Preparing the WebSphere Studio project . . . . . . . . . . . . . . . . . . 71
4.3.2 Generate the order servlet, HTML, and JSP files . . . . . . . . . . . . 74
4.4 Customize the order servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 76
4.5 Publish the order servlet on the test stage . . . . . . . . . . . . . . . . . . . . . 76
4.5.1 Set up Studio publishing for local testing . . . . . . . . . . . . . . . . . . 76
4.5.2 Publish the order files on the test stage . . . . . . . . . . . . . . . . . . . 77
4.6 Test the order servlet in the WebSphere Test Environment . . . . . . . . 78
4.6.1 Set up the Servlet Engine classpath . . . . . . . . . . . . . . . . . . . . . . 78
4.6.2 Run the Servlet Engine. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78
4.6.3 Run the servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 80
4.7 Modify the order beans for publishing on the server . . . . . . . . . . . . . . 81
4.7.1 About the modifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82

iv Creating an Interactive B2B Web Application


4.7.2 Change the code page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
4.7.3 Change the command bean properties . . . . . . . . . . . . . . . . . . . . 83
4.7.4 Change the navigator properties. . . . . . . . . . . . . . . . . . . . . . . . . 84
4.7.5 Export from VisualAge for Java to WebSphere . . . . . . . . . . . . . . 84
4.8 Publish the order servlet on the server . . . . . . . . . . . . . . . . . . . . . . . . 84
4.8.1 Modify the servlet configuration file. . . . . . . . . . . . . . . . . . . . . . . 84
4.8.2 Modify the user interface files . . . . . . . . . . . . . . . . . . . . . . . . . . . 85
4.8.3 Prepare to publish on the host . . . . . . . . . . . . . . . . . . . . . . . . . . 86
4.8.4 Publish the order files on the server . . . . . . . . . . . . . . . . . . . . . . 87
4.8.5 Check the WebSphere Application Server classpath . . . . . . . . . 87
4.8.6 Provide permissions for the published files . . . . . . . . . . . . . . . . . 88
4.9 Test the order servlet from a Web browser . . . . . . . . . . . . . . . . . . . . . 89

Chapter 5. Create the bid servlet. . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 93


5.1 Create Java beans that access MQSeries . . . . . . . . . . . . . . . .. . . . . 93
5.1.1 Create the bid package. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . . 94
5.1.2 Create the BidMessageType record type . . . . . . . . . . . . .. . . . . 94
5.1.3 Create the BidRequest record class . . . . . . . . . . . . . . . . .. . . . . 94
5.1.4 Create the AllBidsMessageType record type . . . . . . . . . .. . . . . 95
5.1.5 Create the AllBidsReply record class . . . . . . . . . . . . . . . .. . . . . 96
5.1.6 Create the BidRequestCommand class . . . . . . . . . . . . . .. . . . . 96
5.1.7 Create the AllBidsReplyCommand class . . . . . . . . . . . . . .. . . . 100
5.1.8 Create the BidsNavigator class. . . . . . . . . . . . . . . . . . . . .. . . . 104
5.2 Test the MQ connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . 109
5.2.1 Create a TestBidsNav test application . . . . . . . . . . . . . . .. . . . 109
5.2.2 Run TestBidsNav to test the MQ connection. . . . . . . . . . .. . . . 111
5.2.3 Create a version of the bid package . . . . . . . . . . . . . . . . .. . . . 112
5.3 Generate the bid servlet and generic user interface files . . . . .. . . . 112
5.3.1 Prepare to generate . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . 112
5.3.2 Generate the bid servlet, HTML, and JSP files . . . . . . . . .. . . . 113
5.4 Customize the bid servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . 115
5.5 Publish the bid servlet on the test stage . . . . . . . . . . . . . . . . . .. . . . 115
5.6 Test the bid servlet in the WebSphere Test Environment . . . . .. . . . 116
5.6.1 Start the WebSphere Test Environment . . . . . . . . . . . . . .. . . . 116
5.6.2 Run the Servlet Engine. . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . 117
5.6.3 Run the servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .. . . . 117
5.7 Publish the bid servlet on the server. . . . . . . . . . . . . . . . . . . . .. . . . 119
5.7.1 Modify the servlet configuration file. . . . . . . . . . . . . . . . . .. . . . 119
5.7.2 Modify the user interface files . . . . . . . . . . . . . . . . . . . . . .. . . . 120
5.7.3 Publish the bid files on the server . . . . . . . . . . . . . . . . . . .. . . . 121
5.7.4 Check the WebSphere Application Server classpath . . . .. . . . 122
5.7.5 Provide permissions for the published files . . . . . . . . . . . .. . . . 122
5.8 Test the bid servlet from a Web browser . . . . . . . . . . . . . . . . .. . . . 123

v
Chapter 6. Create the accept servlet . . . . . . . . . . . . . . . . . . . . . . . . . . 125
6.1 Create Java beans to exchange MQSeries messages . . . . . . . . . . . 125
6.1.1 Create the accept package . . . . . . . . . . . . . . . . . . . . . . . . . . . . 127
6.1.2 Create the AcceptMessageType record type . . . . . . . . . . . . . . 127
6.1.3 Create the AcceptRequestMessage record class . . . . . . . . . . . 128
6.1.4 Create the BothConfMessage record type . . . . . . . . . . . . . . . . 129
6.1.5 Create the BothConfReply record class . . . . . . . . . . . . . . . . . . 130
6.1.6 Create the AcceptRequestCommand class . . . . . . . . . . . . . . . . 130
6.1.7 Create the BothConfReplyCommand class . . . . . . . . . . . . . . . . 132
6.1.8 Create the AcceptNavigator class . . . . . . . . . . . . . . . . . . . . . . . 135
6.2 Test the MQ connection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 140
6.2.1 Create the TestAcceptNav class. . . . . . . . . . . . . . . . . . . . . . . . 140
6.2.2 Run TestAcceptNav to test the MQ connection . . . . . . . . . . . . . 142
6.2.3 Review what you have demonstrated . . . . . . . . . . . . . . . . . . . . 143
6.2.4 Create a version the accept package . . . . . . . . . . . . . . . . . . . . 143
6.3 Generate the accept servlet and generic user interface files. . . . . . . 143
6.3.1 Getting the accept bean files into WebSphere Studio . . . . . . . . 143
6.3.2 Generate the accept servlet, HTML, and JSP files . . . . . . . . . . 144
6.4 Customize the accept servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146
6.5 Publish the accept servlet on the test stage . . . . . . . . . . . . . . . . . . . 147
6.6 Test the accept servlet in the WebSphere Test Environment . . . . . . 147
6.7 Publish the accept servlet on the server . . . . . . . . . . . . . . . . . . . . . . 150
6.7.1 Modify the servlet configuration file. . . . . . . . . . . . . . . . . . . . . . 150
6.7.2 Modify the user interface files . . . . . . . . . . . . . . . . . . . . . . . . . . 151
6.7.3 Publish the accept files on the server . . . . . . . . . . . . . . . . . . . . 152
6.7.4 Provide permissions for the published accept files . . . . . . . . . . 152
6.8 Test the accept servlet from a Web browser . . . . . . . . . . . . . . . . . . . 153
6.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 154

Chapter 7. Create the email servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . 155


7.1 Create the IMS beans . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
7.1.1 Create the package . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 155
7.1.2 Create a RecordType for the input message. . . . . . . . . . . . . . . 155
7.1.3 Create a transaction input record bean . . . . . . . . . . . . . . . . . . . 157
7.1.4 Create a RecordType for the output message. . . . . . . . . . . . . . 157
7.1.5 Create a transaction output record bean . . . . . . . . . . . . . . . . . . 158
7.1.6 Create a command class for the IMS transaction . . . . . . . . . . . 159
7.2 Test the beans in the Websphere Test Environment. . . . . . . . . . . . . 170
7.2.1 Create the test Java Server Page . . . . . . . . . . . . . . . . . . . . . . . 170
7.2.2 Run the Java Server Page locally . . . . . . . . . . . . . . . . . . . . . . . 171
7.3 Create the servlet and add email functionality . . . . . . . . . . . . . . . . . 172

vi Creating an Interactive B2B Web Application


Part 3. Creating the Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 175

Chapter 8. Join the servlets. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177


8.1 Define a Web application in WebSphere Application Server . . . . . . . 177
8.2 Provide the interactive flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179
8.2.1 Create the opening page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 180
8.2.2 Modify the order results page . . . . . . . . . . . . . . . . . . . . . . . . . . 182
8.2.3 Modify the order servlet configuration file . . . . . . . . . . . . . . . . . 184
8.2.4 Modify the bid results page . . . . . . . . . . . . . . . . . . . . . . . . . . . . 185
8.2.5 Modify the bid servlet configuration file . . . . . . . . . . . . . . . . . . . 189
8.2.6 Modify the accept results page . . . . . . . . . . . . . . . . . . . . . . . . . 189
8.2.7 Modify the accept servlet configuration file . . . . . . . . . . . . . . . . 191
8.3 Modify the generated servlets to pass the data. . . . . . . . . . . . . . . . . 192
8.3.1 Understanding the order servlet . . . . . . . . . . . . . . . . . . . . . . . . 192
8.3.2 Understanding the bid servlet . . . . . . . . . . . . . . . . . . . . . . . . . . 193
8.3.3 Modifying the accept servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . 194
8.3.4 Publish and test the Web application files. . . . . . . . . . . . . . . . . 196
8.4 Optionally, enhance the user interface . . . . . . . . . . . . . . . . . . . . . . . 197
8.5 Considerations for developing your own Web applications . . . . . . . . 197

Chapter 9. Troubleshooting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199

Appendix A. Server applications reference information . . . . . . . . . . . 201


A.1 Message syntax . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
A.1.1 Bid messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
A.1.2 Accept messages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
A.2 Server application quick reference . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

Appendix B. Using the additional material . . . . . . . . . . . . . . . . . . . . . . 207


B.1 Locating the additional material on the Internet . . . . . . . . . . . . . . . . . . . 207
B.2 Using the Web material. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
B.2.1 System requirements for downloading the Web material . . . . . . . . 207
B.2.2 How to use the material . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207

Appendix C. Special notices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209

Appendix D. Related publications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213


D.1 IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
D.2 IBM Redbooks collections . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213
D.3 Other resources . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 214
D.4 Referenced Web sites . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 215

How to get IBM Redbooks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 217


IBM Redbooks fax order form . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218

vii
Abbreviations and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219

Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221

IBM Redbooks review . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 225

viii Creating an Interactive B2B Web Application


Figures

1. Order servlet user input interface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6


2. Order servlet results page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
3. Bid servlet input page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
4. Bid servlet results page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
5. Accept servlet input page. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
6. Accept servlet results page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
7. Email test input page . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11
8. Email sent by email servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12
9. The opening page of the Web application . . . . . . . . . . . . . . . . . . . . . . . . . 14
10. The order page of the Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
11. The bids page of the Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
12. The final page of the Web application . . . . . . . . . . . . . . . . . . . . . . . . . . . . 17
13. Our scenario B2B Web application architecture . . . . . . . . . . . . . . . . . . . . 24
14. Starting the Web application: the AcmeStuff.html page. . . . . . . . . . . . . . . 27
15. Order servlet results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
16. Bid servlet results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31
17. Accept servlet results. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33
18. Email confirmation sent to the customer . . . . . . . . . . . . . . . . . . . . . . . . . . 34
19. IMS: /DIS TRAN command output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 38
20. IMS: /DIS DATABASE command output . . . . . . . . . . . . . . . . . . . . . . . . . . 38
21. IMS: /DIS OTMA command output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44
22. IMS Connect: VIEWHWS command output. . . . . . . . . . . . . . . . . . . . . . . . 44
23. RetrieveCustomerCommand class definition. . . . . . . . . . . . . . . . . . . . . . . 52
24. RetreiveCustomerCommand ConnectionSpec properties . . . . . . . . . . . . . 54
25. RetreiveCustomerCommand InteractionSpec properties . . . . . . . . . . . . . 55
26. RetrieveCustomerCommand, CustomerRecord input bean properties . . . 56
27. Order package, with first Command bean, RetrieveCustomerCommand . 57
28. Order package contents, including both Command beans . . . . . . . . . . . . 60
29. CICSRetrieveNavigator properties on the BeanInfo page . . . . . . . . . . . . . 62
30. CICSRetrieveNavigator with property-to-property connections . . . . . . . . . 64
31. All connections in CICSRetrieveNavigator. . . . . . . . . . . . . . . . . . . . . . . . . 66
32. CICSNavExecute main method for testing the order beans . . . . . . . . . . . 68
33. Order package, containing all the beans and a test application . . . . . . . . 69
34. VisualAge for Java Console with CICSNaveExecute results. . . . . . . . . . . 70
35. WebSphere Test Environment window . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
36. Java console in VisualAge for Java . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 79
37. Order servlet input page, in WebSphere Test Environment . . . . . . . . . . . 80
38. Order servlet results page, in WebSphere Test Environment . . . . . . . . . . 81
39. The custorder.servlet, with changes for host publishing . . . . . . . . . . . . . . 85
40. Order servlet, running in WebSphere Application Server . . . . . . . . . . . . . 90

© Copyright IBM Corp. 2001 ix


41. Order servlet results, running in WebSphere Application Server. . . . . . . . 91
42. BidRequestCommand ConnectionSpec properties . . . . . . . . . . . . . . . . . . 98
43. BidRequestCommand InteractionSpec properties. . . . . . . . . . . . . . . . . . . 99
44. BidRequestCommand BidRequest input bean properties . . . . . . . . . . . . 100
45. AllBidsReplyCommand ConnectionSpec properties . . . . . . . . . . . . . . . . 102
46. AllBidsReplyCommand InteractionSpec properties . . . . . . . . . . . . . . . . . 103
47. AllBidsReplyCommand AllBidsReplyoutput bean properties . . . . . . . . . . 104
48. BidsNavigator, in the Visual Composition Editor in VisualAge for Java . . 108
49. The bid package, containing all beans and the navigator . . . . . . . . . . . . 108
50. TestBidsNav main method code, for testing bid beans . . . . . . . . . . . . . . 110
51. Results of running TestBidsNav in VisualAge for Java . . . . . . . . . . . . . . 111
52. The bid servlet input page, running in WebSphere Test Environment. . . 118
53. The bid servlet results page, running in WebSphere Test Environment . 118
54. The shipbids.servlet, with changes for host publishing . . . . . . . . . . . . . . 120
55. Bid servlet input page, in WebSphere Application Server . . . . . . . . . . . . 123
56. Bid servlet results, in WebSphere Application Server . . . . . . . . . . . . . . . 124
57. Accept servlet results, with confirmation code . . . . . . . . . . . . . . . . . . . . . 126
58. BothConfReplyCommand InteractionSpec properties . . . . . . . . . . . . . . . 134
59. AcceptNavigator in Visual Composition editor . . . . . . . . . . . . . . . . . . . . . 137
60. Finished AcceptNavigator, with connections . . . . . . . . . . . . . . . . . . . . . . 139
61. The accept package, containing all the beans and the navigator . . . . . . 139
62. TestAcceptNav main method, for testing accept beans. . . . . . . . . . . . . . 141
63. Results of running TestAcceptNav in VisualAge for Java . . . . . . . . . . . . 142
64. Accept servlet input page, in WebSphere Test Environment. . . . . . . . . . 149
65. Accept servlet results, in WebSphere Test Environment. . . . . . . . . . . . . 150
66. A portion of the acceptdate servlet configuration file . . . . . . . . . . . . . . . . 151
67. Accept servlet input page, in WebSphere Application Server . . . . . . . . . 153
68. Accept servlet results, in WebSphere Application Server . . . . . . . . . . . . 154
69. COBOL to Record Type SmartGuide Commarea Selection Window . . . 156
70. IDE Workbench window with transaction input and output classes . . . . . 159
71. VisualAge for Java Create Command SmartGuide . . . . . . . . . . . . . . . . . 161
72. IMS Connection Specification properties . . . . . . . . . . . . . . . . . . . . . . . . . 162
73. IMS Interaction Specification Properties . . . . . . . . . . . . . . . . . . . . . . . . . 163
74. VisualAge for Java Input Record Bean Selection . . . . . . . . . . . . . . . . . . 164
75. VisualAge for Java Input/Output Record Bean selection . . . . . . . . . . . . . 165
76. The imsemail input bean properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167
77. The imsemail output bean properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . 168
78. The imsemail IMS Interaction Specification properties . . . . . . . . . . . . . . 169
79. The imsemail IMS Connection Specification properties. . . . . . . . . . . . . . 170
80. Source of Imsbeancall.jsp . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
81. Imsbeancall.jsp browser output . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 172
82. Import statements to use SUNs javamail. . . . . . . . . . . . . . . . . . . . . . . . . 173
83. Additional code to send email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173

x Creating an Interactive B2B Web Application


84. Generated email . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174
85. Web application directory structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
86. Web application definition in WebSphere configuration file . . . . . . . . . . . 178
87. AcmeStuff Web application flow, from an internal perspective . . . . . . . . 180
88. AcmeStuff input page, which starts the order servlet. . . . . . . . . . . . . . . . 182
89. Page produced from modified custorderHTMLResults.JSP . . . . . . . . . . 183
90. Code to provide bid servlet for input on order results page . . . . . . . . . . . 184
91. The custorder.servlet modified for AcmeStuffOrder.jsp as results page . 185
92. Page produced from modified shipbidsHTMLResults.jsp . . . . . . . . . . . . 186
93. Code to add order results to bids results page . . . . . . . . . . . . . . . . . . . . 187
94. Code to modify the presentation of the bids results. . . . . . . . . . . . . . . . . 188
95. Code to add the accept servlet invocation . . . . . . . . . . . . . . . . . . . . . . . . 189
96. The shipbids.servlet, modified for AcmeStuffBids.jsp as results page. . . 189
97. Page produced from modified accept servlet results page . . . . . . . . . . . 190
98. Code to customize accept servlet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
99. The acceptdate.servlet modified for AcmeStuffFinal.jsp as results page 192

xi
xii Creating an Interactive B2B Web Application
Tables

1. Server applications on ADS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 12


2. Server processes required to run our scenario . . . . . . . . . . . . . . . . . . . . . 25
3. Jars required by our B2B Web application. . . . . . . . . . . . . . . . . . . . . . . . . 42
4. CustomerRecord generation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
5. CustomerRecord record attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
6. OrderRecord generation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
7. OrderRecord record attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51
8. RetrieveCustomerCommand ConnectionSpec properties . . . . . . . . . . . . . 53
9. RetrieveCustomerCommand InteractionSpec properties . . . . . . . . . . . . . 54
10. CustomerRecord output bean properties. . . . . . . . . . . . . . . . . . . . . . . . . . 56
11. RetrieveOrderCommand ConnectionSpec properties . . . . . . . . . . . . . . . . 58
12. RetrieveOrderCommand InteractionSpec properties. . . . . . . . . . . . . . . . . 59
13. Output properties for RetrieveOrderCommand . . . . . . . . . . . . . . . . . . . . . 60
14. CICSRetrieveNavigator properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61
15. Property-to-property connections for CICSRetrieveNavigator . . . . . . . . . . 63
16. Event-to-method connections for CICSRetrieveNavigator. . . . . . . . . . . . . 65
17. NavCICSConnection properties. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66
18. Studio project properties for WebSphere Application Server . . . . . . . . . . 73
19. Connector related jars required to compile . . . . . . . . . . . . . . . . . . . . . . . . 73
20. Files generated by WebSphere Studio for order servlet . . . . . . . . . . . . . . 75
21. Files published on WebSphere Application Server . . . . . . . . . . . . . . . . . . 87
22. BidRequest generation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
23. BidRequest record attributes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95
24. AllBidsReply generation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
25. AllBidsReply record attributes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96
26. BidRequestCommand ConnectionSpec properties . . . . . . . . . . . . . . . . . . 97
27. BidRequestCommand InteractionSpec properties. . . . . . . . . . . . . . . . . . . 98
28. AllBidsResplyCommand definition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
29. AllBidsReplyCommand ConnectionSpec properties . . . . . . . . . . . . . . . . 101
30. AllBidsReplyCommand InteractionSpec properties . . . . . . . . . . . . . . . . . 102
31. BidsNavigator properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105
32. Property-to-property connections for BidsNavigator . . . . . . . . . . . . . . . . 106
33. Event-to-method connections for BidsNavigator . . . . . . . . . . . . . . . . . . . 107
34. MQConnectionspec properties for BidsNavigator . . . . . . . . . . . . . . . . . . 107
35. Files generated by WebSphere Studio for order servlet . . . . . . . . . . . . . 114
36. Bid files published on WebSphere Application Server . . . . . . . . . . . . . . . 121
37. AcceptRequestMessage generation options . . . . . . . . . . . . . . . . . . . . . . 129
38. AcceptRequestmessage record attributes . . . . . . . . . . . . . . . . . . . . . . . . 129
39. BothConfReply generation options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 130
40. AcceptRequestmessage record attributes . . . . . . . . . . . . . . . . . . . . . . . . 130

© Copyright IBM Corp. 2001 xiii


41. AcceptRequestCommand ConnectionSpec properties . . . . . . . . . . . . . . 131
42. AcceptRequestCommand InteractionSpec properties . . . . . . . . . . . . . . . 132
43. BothConfReplyCommand ConnectionSpec properties . . . . . . . . . . . . . . 133
44. BothConfReplyCommand InteractionSpec properties . . . . . . . . . . . . . . . 134
45. AcceptNavigator properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
46. AcceptNavigator property-to-property connections . . . . . . . . . . . . . . . . . 137
47. AcceptNavigator event-to-method connections . . . . . . . . . . . . . . . . . . . . 138
48. acceptMQConnection properties for the AcceptNavigator. . . . . . . . . . . . 138
49. Files generated by WebSphere Studio for accept servlet . . . . . . . . . . . . 145
50. Data to enter into accept servlet input page . . . . . . . . . . . . . . . . . . . . . . 149
51. Symptom table . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 199
52. Bid servlet request to Hub, requesting shipping bids, on HUBREQQ . . . 201
53. Hub request to each shipper, requesting a shipping bid, on SxREQQ . . 201
54. A shipper reply to Hub, providing a shipping bid, on HUBRESQ. . . . . . . 202
55. Hub reply to bid servlet, providing all shipping bids, on HUBREPQ . . . . 202
56. Accept servlet request message to Hub, on HUBREQQ . . . . . . . . . . . . . 203
57. Accept message from Hub to Shipperx, on SxREQQ . . . . . . . . . . . . . . . 203
58. Reject message from Hub to each Shipper, on SxREQQ . . . . . . . . . . . . 204
59. From Hub to MQ/CICS Bridge, on SYSTEM.C001.BRIDGE.QUEUE . . . 204
60. Reply message from Shipperx to Hub, on HUBRESQ . . . . . . . . . . . . . . 205
61. Reply message from Hub to accept servlet, on HUBREPQ . . . . . . . . . . 205
62. Server component source on ADS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205

xiv Creating an Interactive B2B Web Application


Preface

This IBM Redbook will help you create an interactive Web application using
IBM’s strategic e-development software, including VisualAge for Java,
WebSphere Studio, and WebSphere Application Server.

Using an S/390 server environment and a realistic scenario, you see how to
access enterprise resources in CICS, DB2, IMS, and MQSeries in a modern
Web application.

Part 1, “Overview of the scenario” on page 1, describes the overall scenario,


including the configuration of the server environment, an overview of the
steps you take to create the Web application, and how the scenario pertains
to real world business-to-business scenarios.

Part 2, “Creating the servlets” on page 45, walks you through detailed steps
to create four servlets that provide the foundation for the Web application. You
use VisualAge for Java and WebSphere Studio to develop the servlets. You
deploy them to WebSphere Application Server on OS/390.

Part 3, “Creating the Web application” on page 175, tells how to join the
servlets to form an interactive Web application, involving three interactions
with a user. Finally, you see reference information that may be helpful to you
as you develop this and other Web applications.

Audience
This book is intended to help traditional application programmers, who have
minimal experience developing Web applications, get started with a realistic
application. It is also appropriate for more experienced Web application
programmers who want to know more about using S/390 as a part of a Web
application environment.

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 San Jose Center.

Deborah Cottingham is a Senior Programmer at the IBM Silicon Valley


Laboratory, in San Jose, California. She helps to develop application
integration middleware products, as well as applications and tutorials that
show how to use these products to meet current business requirements. She
has developed applications in a wide variety of languages, on numerous

© Copyright IBM Corp. 2001 xv


platforms, and has taught IBM classes for IBM employees and Business
Partners. She holds a master’s of science in Computer Science from
California State University at Chico.

Denis Gaebler is an IT Specialist at IBM in Germany. He has three years of


experience with IMS/ESA, its connectors, and WebSphere/390. He holds a
degree in business, specializing in Computer Science from Staatliche
Studienakademie Dresden in Germany. His areas of expertise include Web
applications architecture and design for OS/390 Web access including those
for distributed environments. He works extensively at customer sites in
Germany with IMS Connect and the IMS Connector for Java.

We would like to thank the following people for their technical contributions to
this project:

Masaharu Ando, Advisory Software Engineer


IBM Silicon Valley Laboratory, San Jose, California

James Conover, I/S Availability Specialist


IBM Global Services, Buffalo, New York

Barbara Meyers, Senior Software Engineer


IBM Silicon Valley Laboratory, San Jose, California

Kev Senior, SW IT Architect


EMEA South Technical Sales Support, IBM Italy

Peter Siddell, CICS/390 Specialist


CICS/390 Services and Sales, Hursley, England

Paul Spallas, Visual Designer


IBM Silicon Valley Laboratory, San Jose, California

Rick Weaver
Worldwide Technical Consultant for VisualAge for Java/Websphere
IBM Dallas, Texas

We would also like to thank Susan Croce, Marty Shelton, and Tom Ramey
from the IBM Silicon Valley Laboratory, for their support in developing this
book.

xvi Creating an Interactive B2B Web Application


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 225 to
the fax number shown on the form.
• Use the online evaluation form found at ibm.com/redbooks
• Send your comments in an Internet note to redbook@us.ibm.com

xvii
xviii Creating an Interactive B2B Web Application
Part 1. Overview of the scenario

In this first part, you see a description of the overall scenario, including the
configuration of the server environment, an overview of the steps you take to
create the Web application, and how the scenario pertains to real world
business-to-business scenarios.

© Copyright IBM Corp. 2001 1


2 Creating an Interactive B2B Web Application
Chapter 1. Introduction

This book shows you how to create a Web application that lets a user
expedite the delivery of a product ordered through the Internet.

By working through the scenario described in this book, you can see:
• How to create an interactive Web application — that is, one involving
multiple interactions with the user
• How to use connectors to access IBM subsystems on OS/390, including
CICS, MQSeries, DB2, and IMS
• How to save the data acquired by one servlet and reuse it in another
servlet
• How the server was configured to support the application

In the scenario described here, all the server applications are running on a
single S/390 processor. In a real world environment, the server applications
and subsystems which support this application could be spread across
several processors. In fact, some of the server applications would reside on
processors belonging to a set of Business Partners, and those systems may
or may not be S/390. But these are primarily deployment choices; the overall
architecture is still the same.

We call the application described here, with which users interact via the
Internet and which use server applications that would ultimately belong to a
set of Business Partners, an interactive business-to-business (B2B) Web
application.

This book was adapted from a tutorial provided with the IBM WebSphere
Application Development Solution (ADS) for OS/390. For a complete list of
tutorials, see http://www.ibm.com/s390/ads. You do not need access to an ADS
system to use this book; however, if you do have access, you can actually run
the completed application.

1.1 Scenario overview


When you work through the scenario described in this book, you create a
series of servlets and then you connect and deploy them as a complete Web
application. You follow steps similar to those you would take to create your

© Copyright IBM Corp. 2001 3


own servlets to access your own CICS, MQSeries, DB2, or IMS applications
or transactions on OS/390. This scenario entails these major tasks:
1. Create the order servlet to access CICS and DB2, retrieving customer and
order information.
2. Create the bid servlet to access MQSeries, requesting shipping options
from business partners.
3. Create the accept servlet to access MQSeries, CICS, and DB2, updating
order information.
4. Create the email servlet to access IMS, retrieving the customer’s email
address.
5. Customize the servlets to provide interactive application flow.
6. Deploy and test the Web application.

1.1.1 S/390 software prerequisites


You don’t have to have a server environment to create the servlets. You could
just read about the server configuration to get an idea of how you might
configure your own server for your own Web application. However, to learn
the most from this exercise (and to actually deploy and run the servlets), you
need access to an IBM WebSphere Application Development Solution (ADS)
for OS/390 Version 2, or to an S/390 with the following software installed and
configured with:
• OS/390 V2R9 or higher
• CICS Transaction Server for OS/390 V1.3
• DB2 V6.1
• IMS V6.1
• MQSeries V2.1
• WebSphere Application Server, V3.02, Service Level 3
• IBM HTTP Server V5.1
• The server applications

It is possible that other levels of these software components may also work,
but the application was tested with the levels listed here.

You need a userid and password on the system and you need to know its URL
and TCP/IP host name.

4 Creating an Interactive B2B Web Application


See also 1.3, “Overview of the server environment” on page 12 and
Chapter 3, “About the server configuration” on page 23.

If you are not using ADS and you actually want to run the completed Web
application, you will also need to install the back-end server applications on
your 390 system. See Appendix A, “Server applications reference
information” on page 201.

1.1.2 Windows NT client software prerequisites


To create the servlets, you need a Windows NT. 4.0 client (Service Pak 4 or
higher), with the following software installed and configured:
• IBM VisualAge for Java V3.02
• IBM WebSphere Studio V3.5
• A recent Java-enabled Web browser, such as Netscape 4.7

Before attempting this scenario, you should have some experience using
VisualAge for Java. If you do not, you might want to go through the VisualAge
for Java tutorial.

To get to the tutorial, after you install VisualAge for Java:


1. Click Start -> Programs -> IBM VisualAge for Java for Windows -> IBM
VisualAge for Java.
2. Click Help -> Help Home Page.
3. In the navigation menu on the left, select Concepts -> Visual
composition -> Visual programming fundamentals.

1.2 Overview of the servlets


This scenario involves four servlets that are joined together to form a fictitious
company Web application, described in 1.4, “Overview of the Web
application” on page 13. Each servlet manages some interaction with a user
and with a server application.

As you create each servlet, you also create an HTML page to provide an
initial user interface to it. When the user clicks a button on the page, one of
the corresponding servlets gets control. That servlet processes a request and
generates a reply page using a Java Server Page (JSP) file and dynamically
acquired data, which is based on the user's input.

Let’s look at each stand-alone servlet briefly.

Chapter 1. Introduction 5
1.2.1 Order servlet
The order servlet gets control when a user enters a customer number on the
order input page and clicks the get order button, as shown in Figure 1.

Figure 1. Order servlet user input interface

The order servlet sends two requests, in the form of CICS ECI calls, to two
server applications, V2CSTDB and GETORDRS, running in CICS on the
server. These applications provide customer and order information from two
DB2 tables. The order servlet generates a reply page, similar to the one in
Figure 2.

6 Creating an Interactive B2B Web Application


Figure 2. Order servlet results page

1.2.2 Bid servlet


The bid servlet gets control when a user enters a date on the bid input page
and clicks the expedite button as shown in Figure 3.

Chapter 1. Introduction 7
Figure 3. Bid servlet input page

The bid servlet sends a request, in the form of an MQSeries message, to a


server application, MQHUB, on the server. MQHUB sends additional
messages to three additional applications, SHIPR1, SHIPR2, and SHIPR3.
The SHIP applications provide delivery options, in the form of MQSeries
messages that are consolidated and returned by MQHUB to the bid servlet.
The bid servlet creates a response page, similar to Figure 4.

8 Creating an Interactive B2B Web Application


Figure 4. Bid servlet results page

1.2.3 Accept servlet


The accept servlet gets control when a user enters data describing the
preferred delivery option on the accept servlet input page and clicks the
expedite button, as shown in Figure 5.

Chapter 1. Introduction 9
Figure 5. Accept servlet input page

The accept servlet sends a request, in the form of an MQSeries message, to


the MQHUB server application on the server. MQHUB sends messages to the
SHIPRx applications indicating which shipping option was accepted. MQHUB
also puts a message on the MQ/CICS Bridge to run a CICS application to
update the order information to reflect the new shipping option.

After MQHUB receives confirmation from the MQ/CICS and the appropriate
SHIPRx application, MQHUB sends a confirmation message to the accept
servlet. The accept servlet creates a response page, similar to Figure 6.

10 Creating an Interactive B2B Web Application


.

Figure 6. Accept servlet results page

1.2.4 Email servlet


The stand-alone email servlet gets control when a user enters a customer
number into the email input page and clicks the Submit button, as shown in
Figure 7.

Figure 7. Email test input page

Chapter 1. Introduction 11
The email servlet sends a request to an IMS transaction, JAVATRAN, which
accesses an IMS database called JAVADB and retrieves the OUT_EMAIL _ID
field. Then the email servlet creates and sends an email that looks similar to
Figure 8.

Please respond to mailer@ads.imsmvs.ibm.com


To:WEAVER@MVSIMS.IBM.COM
Subject: confirmation
Dear RICK WEAVER,
Your order will be expedited as promised.
Thank you for shopping at AcmeStuff!

Figure 8. Email sent by email servlet

The individual servlets provide the discrete functions we want. Later you will
see how the servlets are joined to provide one continuous, interactive Web
application, but next let’s take a quick look at the server environment.

1.3 Overview of the server environment


The server must have the applications that implement the servlet requests. If
you are using ADS, the server applications, which are listed in Table 1, are
already installed.
Table 1. Server applications on ADS

Application Subsystem Purpose

V2CSTDB CICS To retrieve CUSTOMER information

GETORDRS CICS To retrieve ORDER information

ORUPDATE CICS To update ORDER information

MQHUB MQSeries To get messages from a servlet and put messages on


the queues of the appropriate serving applications

SHIPR1 MQSeries To provide delivery options from shipping vendors on


SHIPR2 behalf of AcmeStuff
SHIPR3

JAVATRAN IMS To retrieve the customer’s email address

In a production environment, the SHIPRx applications would be remote; that


is, they would reside on the machines of the business partners, which may or

12 Creating an Interactive B2B Web Application


may not be S/390 machines. The applications “communicate” through
messages managed by an MQSeries Queue Manager.

To see the source for the server applications, see Appendix B, “Using the
additional material” on page 207. If you examine the source, you see many
techniques that you could use to implement your own Web applications,
including:
• Retrieving and updating data from DB2 tables, using COBOL applications
running in CICS (VSCSTDB, GETORDRS, ORUPDATE)
• Using MQSeries queues (MQHUB, SHIPRx)
• Getting and putting MQSeries messages from COBOL programs (SHIPRx)
• Getting and putting MQSeries messages from a C++ program (MQHUB)
• Starting a CICS application by sending a message to the MQ/CICS bridge
(MQHUB)
• Getting reply messages from the MQ/CICS bridge (MQHUB)
• Managing MQSeries multiple messages in a single unit of work (MQHUB)
• Retrieving data from an IMS database, using a COBOL application
(JAVATRAN)

Most of this scenario is about creating and deploying servlets that use these
applications on a preconfigured server environment. However, to learn more,
see Chapter 3, “About the server configuration” on page 23.

1.4 Overview of the Web application


The servlets are the basis for a Web application belonging to a fictitious
company called AcmeStuff. In this section, we provide an overview of how the
servlets are joined to form the Web application. First, we describe what the
user will see when the application is complete. Then generally, we describe
how the programmer, following the detailed steps in this book, joins the
servlets into a Web application.

1.4.1 From the user’s perspective


This Web application lets a user expedite delivery of a product already
ordered from a fictitious company called AcmeStuff. We assume a person:
• Has ordered an item from AcmeStuff
• Wants the item delivered sooner than originally promised
• Is willing to pay an additional shipping charge for faster delivery
• Requests the item be expedited through the AcmeStuff Web site

Chapter 1. Introduction 13
When a customer orders a product, AcmeStuff provides a delivery date,
assuming delivery by a low-cost delivery service. This service is not always
the fastest way that an item can be delivered, so AcmeStuff provides
additional delivery options through Business Partners who specialize in fast
delivery. In this scenario, the Business Partners are called SHIPPER1,
SHIPPER2, and SHIPPER3.

To see how the application might look from the user’s perspective, let's look at
a typical customer interaction by a customer named Rick.
1. Our customer, Rick, starts the application by opening a URL similar to the
following in his Web browser (Figure 9):
http://9.117.56.217/demos/b2bapp/html/AcmeStuff.html

Figure 9. The opening page of the Web application

2. Rick goes to the AcmeStuff Web enters his previously assigned customer
number and clicks the getorder button.
He sees information about the product he previously ordered, along with
his name and shipping address, similar to Figure 10.

14 Creating an Interactive B2B Web Application


Figure 10. The order page of the Web application

3. Rick types in his preferred delivery date and clicks the expedite button.
He sees several shipping options offered by SHIPPER1, SHIPPER2, and
SHIPPER3, similar to the following. The shipping vendors provide the
closest date and best price with which they can deliver the item, similar to
Figure 11.

Chapter 1. Introduction 15
Figure 11. The bids page of the Web application

4. Rick clicks the accept button that corresponds to his preferred shipping
option.
He sees a new page, as shown in Figure 12, with a confirmation code
indicating the item will be expedited according to his selected shipping
option. He also receives an email confirming the expedited delivery.

16 Creating an Interactive B2B Web Application


Figure 12. The final page of the Web application

1.4.2 From the programmer’s perspective


In the Web application, the servlets are linked together through the user
interface and by sharing data using an HTTPSession object. The Web
application would flow like this:
1. The application starts when a user enters a URL into a Web browser
similar to the following one:
http://9.117.56.217/demos/b2bapp/html/AcmeStuff.html
2. The programmer would have published the html page so that IBM HTTP
Server, the Web server, could find it.
3. When the person enters a customer number and clicks the getorder
button, the order servlet gets control. It accesses CICS on the server and
displays the customer and order information, using a results page JSP.

Chapter 1. Introduction 17
The programmer would have added a date field and the expedite button to
the order results Java Server Page (JSP) so the customer has a way to
start the next part of the application. Also, the programmer would have
made the order servlet store the data it retrieved in an Http Session object
for later use by the accept servlet.
4. When the person enters a new date and clicks the expedite button, the bid
servlet gets control. The delivery options are provided by the SHIPRx
programs, using MQSeries messaging and the MQHUB routing
application.
The programmer would have added accept buttons to correspond to each
of the shipping options on the bid servlet results JSP. Also, the
programmer would have caused the bid servlet to store the shipping
option in the Http Session for later use by the accept servlet.
5. When the user decides on one of the delivery options and clicks its accept
button, the accept servlet gets control and passes the data to the MQHUB
server application. After the order table and the selected shipping vendor
have updated their respective databases with the new delivery date,
MQHUB returns a confirmation code to the accept servlet.
The programmer would have modified the original accept servlet to
retrieve the order and bid data stored in the Session object, rather than
require the user to key it in. Also, the programmer would modify the accept
servlet results page to first display the confirmation code in the results
Web page and then call the e-mail servlet to get the customers email
address and send the customer a confirming email.
The rest of this book tells you how to perform all the tasks described in this
chapter. So, let’s get started!

18 Creating an Interactive B2B Web Application


Chapter 2. Install the development software

In this chapter you install the client software that you use to develop the
servlets for the Web application. We assume you have access to an ADS
system, or to a S/390 with a similar configuration. See Chapter 3, “About the
server configuration” on page 23, for a description of the server environment.

If you have not done so already, install the following software on your
Windows NT (with Service Pack 4) client:
• IBM VisualAge for Java V3.02
• VisualAge for Java features
• IBM WebSphere Studio V3.5
• A Web browser
• Demo files

Your Windows NT client and your S/390 server must be configured to use
TCP/IP.

2.1 Install IBM VisualAge for Java V3.02


Use VisualAge for Java Version 3.02 for this scenario.

Follow the instructions in the VisualAge for Java Readme on the CD before
you begin. If you have installed an earlier release of VisualAge for Java, you
should export any projects that you want to save and uninstall the earlier
release completely before you install Version 3.02.

When you are ready to install VisualAge for Java Version 3.02, insert the CD
into your CD drive and follow the instructions that display in the installation
program, noting the following:
1. Throughout this Redbook, we reference the path where you choose to
install VisualAge for Java as < vajpath> .
2. Select Full install.
Alternatively, select Custom install and select Select Transactions
Access Builder.
3. Optionally, install the Distributed Debugger. This book does not include
any steps involving the Distributed Debugger, but you may find it helpful.
4. Unless you regularly work in a team repository environment, select Local
for the location of the repository.

© Copyright IBM Corp. 2001 19


5. After the installation program is finished, restart your computer and let the
installation process complete.

2.2 Install VisualAge for Java features


You need to add some features to your VisualAge for Java workspace.
1. Click Start -> Programs ->IBM VisualAge for Java for Windows-> IBM
VisualAge for Java for Windows.
2. If this is the first time that you have started this release, select
Administrator and enter your Windows NT logon user ID for the network
ID.
3. After VisualAge for Java completes its installation initialization process, in
the Welcome window, select Go to the Workbench and click OK.
4. Click File -> Quick Start -> Features -> Add Feature and click OK.
5. Hold down the Ctrl key, select these features, and click OK:
IBM Common Connector Framework 3.01
IBM Enterprise Access Builder Library 3.02
IBM WebSphere Test Environment 3.02
MQSeries Connector 1.1
IMS TOC Connector 1.2.1
CICS Connector CICS 3.0.4
Servlet IDE Utility Library 3.02

VisualAge for Java may add some other features that it requires to work with
these features.

2.3 Install IBM WebSphere Studio 3.5


Install IBM WebSphere Studio, taking all the defaults, unless you want to
change the install directory.

Important: Throughout this tutorial, we refer to the Studio installation path as


<studiopath> ; that is, <studiopath> refers to:
<drive:>\WebSphere\Studio35

20 Creating an Interactive B2B Web Application


Optionally, install these WebSphere Studio features, which are not used in
this scenario:
• IBM WebSphere Applet Designer
• IBM WebSphere Page Detailer
• BM Distributed Debugger

2.4 Install a Web browser


Install a current Java-enabled Web browser. This scenario was tested using
Netscape Communicator 4.7 and Netscape 4.72.

2.5 Install the demo files


To get the demo files, see Appendix B, “Using the additional material” on
page 207.

You use some of the demo files to help you build the servlets. You examine
other demo files to understand how the server applications work and to see
how the server is configured.

Chapter 2. Install the development software 21


22 Creating an Interactive B2B Web Application
Chapter 3. About the server configuration

This chapter tells how the server was configurated to support this scenario.
First, to give you a frame of reference with which to discuss the configuration,
you see how the application flows from an internal perspective. Then you see
how the subsystems were configured on the ADS system to support our Web
application components.

3.1 About the application flow


In the discussion that follows, you see what happens inside the application as
the user interacts with it. Refer to Figure 13 as you read through the flow.

© Copyright IBM Corp. 2001 23


24
JAVATRAN

JAVADB
IMS Transaction Manager

IMS Database Manager

IBM HTTP Server


HUBREPQ

AcmeStuff.html
MQHUB
WebSphere C ++ Application

Creating an Interactive B2B Web Application


HUBREQQ
Application Studio
/order /accept SHIPR 3
/bid /imsemail COBOL Application

Figure 13. Our scenario B2B Web application architecture


/general S3REQQ

AcmeStuffOrder.jsp
AcmeStuffBids.jsp MQ/CICS Bridge
AcmeStuffFinal.jsp SHIPR 2
COBOL Application
SREQQ
2
CICSRPQ
CTG

SHIPR 1
COBOL Application
SREQQ
1
V2CSTDB GETORDRS UPDATE

CICS Demo Region

HUBRESQ

CUSTOMERS ORDERS

DB2 AIS Database


In this scenario, the host components are running on a single S/390. In a
production environment, the components may be spread across several
machines, which may or may not be S/390 machines. For example, the
SHIPRx applications would be remote; that is, they would reside on the
machines of the Business Partners.

3.1.1 Getting started


This section tells you what must be running on the server to drive the Web
application.

3.1.1.1 Starting the server processes


Before the user can start the application, the subsystems and several of the
server applications must be started. If you are using the ADS system, use
SDSF -> DA to display the active jobs. Each of the processes listed in Table 2
should be active.
Table 2. Server processes required to run our scenario

Jobname Purpose

CICSC001 The ADS CICS demonstration region, in which the


CICS/COBOL/DB2 demo applications (V2CSTDB, GETORDRS,
and ORUPDATE) are installed and configured.

JGATE01 CICS Transaction Gateway, which receives CICS requests from the
servlet, passes them to the CICS region, and returns the reply to
the servlet.

DBA1MSTR DB2 process.

IMS1ITOC IMS connector process.

IMWEBSRV WebSphere Applications Server V3.02.


This process also includes IBM HTTP Server, the Web server.

MQA1MSTR MQSeries Queue Manager, whose name is MQA1.

MQA1CHIN MQSeries server connection channel, which listens for incoming


client connections on a TCP/IP port.

MQHUBCPP A C++ application called MQHUB, which routes MQ messages


between a servlet and the SHIPRx server applications.

MQSHIPR1 A COBOL application called SHIPR1, which provides delivery


options from the Shipper1 shipping vendor.

MQSHIPR2 A COBOL application called SHIPR2, which provides delivery


options from the Shipper2 shipping vendor.

Chapter 3. About the server configuration 25


Jobname Purpose

MQSHIPR3 A COBOL application called SHIPR3, which provides delivery


options from the Shipper3 shipping vendor.

3.1.1.2 Starting the MQSeries server applications


The MQSeries server applications for this scenario (MQHUBCPP, SHIPR1,
SHIPR2, and SHIPR3) must be started so that they can exchange messages
with the bid and accept servlets. Check with your system administrator to
start the subsystem processes listed in Table 2, if they are not running.

To start the server application processes, which must be active:


1. Log on to your server machine where the applications are installed (such
as, an ADS machine or another S/390 on which the ADS image has been
installed).
2. Open ISPF, go to the Data Set List Utility, and press Enter.
3. For the Dsname Level field, type:
DEMOS.MQB2B
4. Press Enter and then browse DEMOS.MQB2B.JCL.
5. To start the Shipper applications, SHIPRx, submit each of these jobs:
SHIPR1GO
SHIPR2GO
SHIPR3GO
6. Exit from DEMOS.MQB2B.JCL and browse DEMOS.MQB2B.CPPJCL.
7. To start the Hub process, MQHUBCPP, submit the MQHUBGO job.
8. Go to ADS -> SDSF -> DA and verify that all four jobs are in GO status.

3.1.1.3 Starting the Web application


To start the application, the user enters a Web address similar to this in a
Web browser:
http://<server IP address>/demos/b2bapp/html/AcmeStuff.html

The IP address is the IP address of the server on which the application is


installed. In this scenario, all the components are installed on a single S/390;
however, that is not required. For example, you could install the Web server
(IBM HTTP Server), the servlet, and the HTML on a separate system from the
serving application components.

The Web server downloads the AcmeStuff.html page to the Web browser,
which displays it for the user, as shown in Figure 14.

26 Creating an Interactive B2B Web Application


Figure 14. Starting the Web application: the AcmeStuff.html page

3.1.2 Retrieving customer order information


After the customer enters his customer number in the AcmeSutff.html page
and clicks the get order button, control passes to the Web server, which, in
our case, is on the S/390 server.

To retrieve information about the customer:


1. The Web server locates the order servlet installed in
/demos/b2bapp/servlets/order/ordr.class and passes it the customer
number as an input parameter. The order servlet runs under the control of
WebSphere Application Server.
2. The servlet passes an EXCI request to the CICS Transaction Gateway
(CTG), to run the V2CSTDB COBOL program. VTCSTDB has been
installed in the DEMOS group, in the CICS demonstration region,
CICSC001, whose applid is A06C001. The EXCI request provides a
commarea that contains the customer number.
Because the servlet is running on the same system as CICS, the servlet
passes its EXCI request to CTG through a local interface. No listener is
required (unlike the case of an applet, which must make the request from
a remote client).
Real World: The CICS configuration on ADS does not require a user ID
and password. However, the CICS Connector, which is used to connect to
CICS, does require a user ID and password. We have included a default

Chapter 3. About the server configuration 27


user ID and password of USERID and PASSWORD. ADS ignores them. In
a real environment, you may require a unique user ID and password. In
this case, you could create a module that would retrieve the appropriate
user ID and password based on the customer number.
3. V2CSTDB sends a static SQL call to the DB2 CUSTOMER table, in the
AIS database, to retrieve the customer information for the specified
customer number.
4. DB2 returns the customer information to V2CSTDB, which places it in the
CICS commarea, and returns control to CICS.
5. CICS returns the commarea through CTG to the order servlet.

To retrieve information about the customer's order:


1. The order servlet passes a second EXCI request, with a commarea
containing the customer number, through CTG to run the GETORDRS
program, also installed in the CICS region, CICSC001.
2. GETORDRS sends a static SQL call to the DB2 ORDERS table, in the AIS
database, to retrieve the customer's current order information.
3. DB2 returns the order information to GETORDRS, which puts it in the
CICS commarea and returns control to CICS.
4. CICS returns the commarea through CTG to the order servlet.
5. The order servlet passes the data from the two CICS applications to the
Java server page, ordrResults.jsp, which formats the data and returns the
HTML to the Web browser to display, similar to Figure 15.

28 Creating an Interactive B2B Web Application


Figure 15. Order servlet results

3.1.3 Requesting shipping options


The user examines his order and may decide to expedite it. To see what
shipping options are possible, he enters his desired shipping date and clicks
the expedite button. Control passes to the Web server which starts the bid
servlet, passing to it the date entered by the user.

Recall that the Hub (MQHUBCPP) and the three shipper applications,
(SHIPRx) are all running. When these applications were started, they
connected to the Queue Manager, MQA1, and opened the appropriate
queues for getting and putting messages. They are constantly monitoring
their respective request queues for new work.
1. The bid servlet uses the MQConnector to connect to MQA1 and to put a
message on the request queue, HUBREQQ, which is monitored by the

Chapter 3. About the server configuration 29


HUB application. The message includes a message type of BID, to
indicate the message is a request for bids from the shippers, and the
desired date that the user entered. This message format is decided by the
Web application programmer. See “Message syntax” on page 201.
Real World: The MQConnector is one of the e-connectors provided by
VisualAge for Java in the Enterprise Access Builder feature. The mqccf.jar
file contains the set of classes that wrap the MQSeries Client Classes for
Java. Depending on the platform you use for your server environment, you
may want to consider writing to the client classes directly, or even to the
MQ Base Java classes. Your options will evolve with time. See also
Section 8.5, “Considerations for developing your own Web applications” on
page 197.
2. The Hub reformats the servlet message into the required format for each
shipper and puts individual messages, of type BID, on each of the shipper
request queues, SxREQQ. See Figure 13, “Our scenario B2B Web
application architecture” on page 24.
Real World: In a real environment, the shipper queues would be on
remote systems from the MQHUB. Connections between different systems
would be handled through individual MQSeries channels. For more
information about working with messages on remote queues, see the MQ
Intercommunication Guide at: http://www.ibm.com/software/mqseries.
You might choose to replace the Hub with another IBM product, called
MQSeries Integrator (MQSI). In this scenario, we did not have access to
the MQSeries Integrator, so we wrote the MQHUB application to provide
the message routing function.
3. Each shipper application places a message of type ABID on the MQHUB
response queue, HUBRESQ.
The shipper applications, SHIPR1, SHIPR2, and SHIPR3, are simple
COBOL applications that provide response messages of type ABID. An
ABID message contains the closest date and lowest price the shipper can
offer for the user’s requested delivery date.
4. The Hub consolidates the messages from the shippers and returns a
single message of type ALLBIDS to the servlet. The Hub places the
message on the Hub’s reply queue, HUBREPQ, which is monitored by the
servlet.
5. The bid servlet uses the Java Server Page (JSP), AcmeStuffBids.jsp, to
format the shipper’s bids and returns the HTML to the Web browser to
display, similar to Figure 16.

30 Creating an Interactive B2B Web Application


Figure 16. Bid servlet results

3.1.4 Accepting a bid


To accept one of the shipping bids, the user clicks the accept button which
corresponds to his preferred choice. Control passes to the Web server which
starts the accept servlet, passing it the accept button’s name/value pair.

Chapter 3. About the server configuration 31


1. The accept servlet puts a message of type ACCEPT on the Hub request
queue, HUBREQQ. The message contains the name of the shipper whose
bid the user accepted.
2. The Hub retrieves the message, revises it slightly, and places the revised
ACCEPT message on the request queue, SxREQQ, belonging to the
shipper whose bid was accepted. The Hub also puts REJECT messages
on the requests queues of the other two shippers.
3. In this scenario, when a shipper is notified that its bid was accepted, the
application responds with an immediate confirmation message, but no real
update occurs.
Real World: In a real environment, each shipper application, running on a
remote system, would update its own company's database, which could be
on the same system as the shipper application, or it could be on a remote
system. In the latter case, the shipper application could use MQSeries to
send a message to that remote system, which would have an application
standing by to perform the update.

The AcmeStuff ORDERS table needs to be updated with the revised delivery
information and the customer needs to see confirmation summarizing the
transaction.
1. The Hub sends a message through the MQ/CICS Bridge to run the
ORUPDATE COBOL program installed in the CICS demonstration region,
CICSC001.
2. The bridge extracts data from the message and builds a commarea that
contains the customer number, shipper's name, new ship date, and new
shipping cost.
3. The ORUPDATE COBOL program receives the commarea and sends an
SQL call to update the DB2 ORDERS table with the revised delivery
information.
4. DB2 returns an SQL message code indicating a successful update.
5. CICS returns the commarea to the Hub, through a dedicated Hub
response queue, CICSRPQ.
6. After the Hub gets confirmation from both the shipper and the MQ/CICS
bridge, it puts a message of type BOTHCONF onto HUBREPQ.
MQHUB creates a unit of work to coordinate the confirmation by the
shipper and the update to AcmeStuff’s ORDERS table before putting the
BOTHCONF message. The BOTHCONF message tells the servlet it is
safe to send confirmation to the customer. If any part of the unit of work
fails, MQHUB returns a message of type ERROR.

32 Creating an Interactive B2B Web Application


7. The accept servlet uses the Java Server Page, AcmeStuffFinal.jsp, to
format and return the confirmation page to the Web browser to display
(Figure 17).

Figure 17. Accept servlet results

8. Finally, the AcmeStuffFinal.jsp calls the email servlet, passing it the


customer number.

3.1.5 Emailing the customer


To make sure the user is notified that his order will ship on the new date he
requested, the Web application sends an email to the customer. Customer
data has already been retrieved from the DB2 CUSTOMER table, by the order
servlet. The order servlet saved this information in a Session object, so any
servlet in the application has access to it. However, the CUSTOMER table
does not have the customer’s email address. Fortunately, an IMS database,

Chapter 3. About the server configuration 33


JAVADB, does have the email address. The Web application uses the email
servlet to retrieve it.

After the AcmeStuffFinal.jsp passes control to the email servlet:


1. The email servlet gets the customer number from the Session object.
2. The email servlet uses the IMS Connector for Java (a feature in VisualAge
for Java) to access IMS, run the JAVATRAN transaction. JAVATRAN
accesses the JAVADB database and retrieves the customer’s email
address.
3. The email servlet uses the javamail and jaf classes to send an email to the
customer, similar to the one in Figure 18.

Please respond to mailer@ads.imsmvs.ibm.com


To:WEAVER@MVSIMS.IBM.COM
Subject: confirmation
Dear RICK WEAVER,
Your order will be expedited as promised.
Thank you for shopping at AcmeStuff!

Figure 18. Email confirmation sent to the customer

Real World: The email servlet could also get the new shipping date, new
shipping cost, item description, and item number from the Session object and
include them in the email message.

3.2 About the server applications


This section tells how the server applications were installed on the S/390
ADS. See Appendix B, “Using the additional material” on page 207 for
information on obtaining a zip file that contains most of the datasets
mentioned below.

3.2.1 About the customer and order applications


The order and accept servlets access three COBOL/CICS/DB2 applications
which retrieve and update the CUSTOMER and ORDERS tables in DB2.
These are the steps required to create and populate the tables and to install
the three applications (V2CSTDB, GETORDRS, and ORUPDATE) on the ADS
image.
1. Create the CUSTOMER table, using DEMOS.EBUS.JCL(TABLES).

34 Creating an Interactive B2B Web Application


2. Populate the CUSTOMER table, using DEMOS.EBUS.JCL(DATA).
3. Pre-process, compile, and link V2CSTDB, using:
- Source: DEMOS.EBUS.JCL(V2CSTDB)
- JCL: DEMOS.EBUS.JCL(CSTJOB)
- PROC: DEMOS.EBUS.JCL(DB2CXCOB)
4. Create the ORDERS table, using DEMOS.MQB2B.JCL(ORDRTABL).
5. Populate the ORDERS table, using DEMOS.MQB2B.JCL(ORDRDATA).
6. Pre-process, compile, and link GETORDRS, using:
- Source and JCL: DEMOS.MQB2B.JCL(ORDRJOB)
- PROC: DEMOS.MQB2B.JCL(DB2CXCOB)
7. Pre-process, compile, and link ORUPDATE, using:
- Source and JCL: DEMOS.MQB2B.JCL(UPDATJOB)
- PROC: DEMOS.MQB2B.JCL(DB2CXCOB)
8. Bind three applications to DB2, using DEMOS.MQB2B.JCL(BIND).
9. Grant permission to use the three applications, using
DEMOS.MQB2B.JCL(GRANT).
10.Define V2CSTDB to CICS, using group EBUS.
See DEMOCICS.COMMON.CSDDEFS(EBUS) for these definitions.
V2CSTDB is used in other scenarios; therefore, it is in a separate group.
11.Define GETORDRS and ORUPDATE to CICS, using group MQB2B.
See DEMOCICS.COMMON.CSDDEFS(MQB2B).
V2CSTDB is used in other scenarios; therefore, it is in a separate group.
12.Install V2CSTDB in CICS group EBUS.
13.Install GETORDRS and ORUPDATE in CICS group MQB2B.

3.2.2 About the shipper applications


The bid and accept servlets access three shipper applications, through
MQSeries messages. These are the steps required to install the three shipper
applications (SHIPR1, SHIPR2, SHIPR3), which are COBOL applications that
get and put messages to MQSeries queues, on the ADS image.
1. Compile and link each of the Shipperx (where x = 1, 2, or 3) applications,
using:
- Source: DEMOS.MQB2B.COBOL(SHIPRx)

Chapter 3. About the server configuration 35


- JCL: DEMOS.MQB2B.JCL(SHIPxJOB)
- MQ stub for COBOL: DEMOS.COBOL.LOAD(CSQBSTUB)
2. Start each of the shipper applications, using:
- JCL: DEMOS.MQB2B.COBOL(SHIPRxGO)
- MQ Libraries, in this order:
1. MQM.MQMA1.CSQPARMS
2. MQM.SCSQANLE
3. MQM.SCSQAUTH
4. MQM.SCSQLOAD

3.2.3 About the hub application


The bid and accept servlets access the shipper applications, through
MQSeries messages, which are routed by the Hub. These are the steps
required to install the Hub, a C++ application that gets and puts MQSeries
messages, on the ADS image.
1. Pre-process, compile, and link the Hub, using:
- Source: DEMOS.MQB2B.CPPPROG(MQHUB)
- JCL: DEMOS.MQB2B.CPPJCL(MQHUBBND)
- PROC: DEMOS.MQB2B.CPPJCL(HUBPROCB)
2. Start the hub application, using:
- JCL: DEMOS.MQB2B.CPPJCL(MQHUBGO)
- PROC: DEMOS.MQB2B.CPPJCL(HUBPROCG)

3.2.4 About the IMS customer application


The email servlet accesses an IMS database containing customer data using
the JAVATRAN transaction. These are the steps required to install the
JAVADB database and JAVATRAN transaction.
1. DBDGen using:
- Source: DEMOS.IMS.SOURCE(DBD)
- JCL: DEMOS.IMS.JCL(DBDGEN)
2. PSBGens using
- Source: DEMOS.IMS.SOURCE(PSB)
- Source: DEMOS.IMS.SOURCE(PSBLOAD)

36 Creating an Interactive B2B Web Application


- JCL: DEMOS.IMS.JCL(PSBGEN)
3. ACBGen using:
- JCL: DEMOS.IMS.JCL(ACBGEN)
4. Dynamic Allocation member of DB created using:
- JCL: DEMOS.IMS.JCL(DYNAMAL)
5. IDCAMS delete/define using:
- JCL: DEMOS.IMS.JCL(IDCAMS)
6. DBRC Init DB and Init DBDS using:
- JCL: DEMOS.IMS.JCL(DBRCINIT)
7. Java Program for Tran using:
- Source: DEMOS.IMS.SOURCE(JAVAPGM)
- JCL: DEMOS.IMS.JCL(JAVAPJCL)
8. Add the following macros to IMSHQL.INSTALIB(IV3C201T)
*****************************************************
* Visual Age JAVA Sample for IMS Customer Data
*****************************************************
APPLCTN PSB=JAVAPSB,PGMTYPE=TP,SCHDTYP=PARALLEL
TRANSACT CODE=JAVATRAN,MODE=SNGL, X
MSGTYPE=(SNGLSEG,NONRESPONSE,1)
DATABASE DBD=JAVADB,ACCESS=UP HDAM/VSAM
*****************************************************
* LOAD PSB
*****************************************************
APPLCTN PSB=JAVALOAD,PGMTYPE=BATCH LOAD PSBHDAM/VSAM
*****************************************************
9. Save file, update jobcard and run IV3C203J to run IMS TM/DB Stage 1.
IV3C203J creates IV3C301J (input to stage 2).
10.Update job card and run IMS Stage 2 job, IMS.INSTALIB(IV3C301J).
(Shutdown IMS if you plan to do a fullgen.)
11.Copy staging libraries to active libraries (full copy was done using job
DEMOS.IMS(COPY)). If you plan to use online change, then first only
copy to the inactive datasets. The following datasets need to be copied:
a. Copying ims.acblib to ims.acbliba and ims.acblibb
b. Copying ims.matrix to ims.matrixa and ims.matrixb
c. Copying ims.modblks to ims.modblksa and ims.modblksb

Chapter 3. About the server configuration 37


d. Copying ims.format to ims.formata and ims.formatb
12.Restart IMS (only if you did a fullgen) or perform online change.
13.Database JAVADB needs to be loaded using:
- JCL: DEMOS.IMS.JCL(DLT0LOAD)

3.2.5 Check database and transaction


To check that the transaction and the database is defined in IMS, use the
/DIS TRAN and /DIS DATABASE commands.

A successful installed JAVATRAN transaction will result in a /DIS TRAN


JAVATRAN command execution, as shown in Figure 19.

R 39,/DIS TRAN JAVATRAN


IEE600I REPLY TO 39 IS;/DIS TRAN JAVATRAN
DFS000I TRAN CLS ENQCT QCT LCT PLCT CP NP LP SEGSZ SEGNO
PARLM RC IMS1
DFS000I JAVATRAN 1 559 0 65535 65535 1 1 1 0 0
NONE 0 IMS1
DFS000I PSBNAME: JAVAPSB IMS1
DFS000I *00354/212158* IMS1
42 DFS996I *IMS READY* IMS1

Figure 19. IMS: /DIS TRAN command output

A successful installed JAVADB database will result in a /DIS DB JAVADB


output as shown in Figure 20.

R 42,/DIS DB JAVADB
IEE600I REPLY TO 42 IS;/DIS DB JAVADB
DFS000I DATABASE TYPE TOTAL UNUSED TOTAL UNUSED ACC CONDITIONS
IMS1
DFS000I JAVADB DL/I UP ALLOCS
IMS1
DFS000I *00354/212210* IMS1
43 DFS996I *IMS READY* IMS1

Figure 20. IMS: /DIS DATABASE command output

38 Creating an Interactive B2B Web Application


3.3 About the subsystem configuration
Now that you have examined the application components, let’s look at how
the subsystems were configured to support them. For general configuration
information about the ADS system see the ADS V2 System Configuration
documentation available from the ADS Web site:
http://www.ibm.com/s390/ads

3.3.1 About MQSeries configuration


Because the entire scenario is implemented using a single server, there is
only one queue manager, the default queue manager configured on ADS,
MQA1. Therefore, the queues are defined as LOCAL in
MQM.MQA1.SCSQPROC(MQB2B).

Real World: In a production environment, each shipping vendor would have


its own queue manager and queues on its system. Therefore, the shipping
queue manager and queues would be remote, and so you would need to
change the definition of the queues to REMOTE.

MQM.MQA1.SCSQPROC(MQB2B) was concatenated into the CSQINP2 DD


in SYS1.PROCLIB(MQA1MSTR), the MQA1 address space JCL. Therefore,
its definitions are initiated when the queue manager is started.

To run COBOL applications that access MQ queues, specify the following MQ


libraries in the JCL. For an example, see DEMOS.MQB2B.JCL(SHIPR1GO),
which runs the first shipper application, SHIPR1.

To access the ADS default queue manager from another system, access port
1414, on which the queue manager is listening.

The channel definition is in MQM.MQA1.SCSQPROC(CSQ4INSG). The


channel name is SYSTEM.DEF.SVRCONN.

To use the MQ connector on S/390, the MQ Client Attachment feature. No


special configuration was installed on ADS.

3.3.2 About MQ/CICS Bridge configuration


The queue manager is defined in MQM.MQA1.SCSQPROC(CSQ4CKBM).
The queue name is SYSTEM.C001.BRIDGE.QUEUE.

We needed to associate the MQBBPLAN plan with the ORUPDATE program.


The CKBP DB2ENTRY CICS resource definition was added so that

Chapter 3. About the server configuration 39


ORUPDATE could be initiated through the bridge. CKBP is a CICS-supplied
transaction that gets control when a message is put on the bridge queue.

3.3.3 About CICS configuration


CICS definitions are specified in DEMOCICS.COMMON.CSDDEFS(MQB2B).
An entry for the MQB2B group was added to
DEMOCICS.COMMON.CSDDEFS(DEMOLIST). Therefore, if you stop and
restart the CICS region, the MQB2B group is reinstalled. Also, MQB2B
reuses definitions in the EBUS group, and so it is restarted as well. See
DEMOCICS.COMMON.CSDDEFS(EBUS). EBUS is also in DEMOLIST.

To add the definitions to DFHCSD, the CICS definitions list, we used


DEMOS.MQB2B.JCL(DEFMQB2B). It uses the DFHCSDUP utility.

Load modules for CICS/COBOL programs, GETORDRS and ORUPDATE, are


in DEMOS.CICS.LOAD, which CICS can find.

We added entries into DEMOCICS.COMMON.TABSRC(DFHCNV) for


GETORDRS and ORUPDATE so their commareas would be converted
between ASCII and EBCDIC during the development phase; that is, when you
test the order and accept beans from VisualAge for Java. The entry that had
already been added for V2CSTDB is also used when you test the order
servlet from VisualAge for Java.

To enable character translation for the GETORDRS program, which is called


by the order servlet and to associate the correct DB2 plan, MQBBPLAN, we
needed to define a transaction that uses the CICS-supplied transaction,
CPMI. However, there was already a transaction named CPMI defined in the
EBUS group and it used a different DB2 plan, EBUSPLAN. So we created a
clone of DFHMIR, called DFHMIRRS, and then created a transaction
definition and DB2ENTRY definition, each called MQCP, which reference
DFHMIRRS and MQBBPLAN.

See also the CICS section of the ADS V2 System Configuration


documentation available from the ADS Web site:
http://www.ibm.com/s390/ads

3.3.4 About DB2 configuration


DEMOS.MQB2B.JCL(BIND) creates a plan used by the MQB2B applications.
The plan name is MQBBPLAN, which is specified in the DB2 entry of the
CICS definitions. The plan uses packages MQB2B and EBUS.

40 Creating an Interactive B2B Web Application


DEMOS.MQB2B.JCL(GRANT) grants execution access to the plan
MQBBPLAN.

Jobs DEMOS.MQB2B.JCL, members ORDRTABL and ORDRDATA, define


and populate the ORDERS table. DEMO.EBUS.JCL, members TABLES and
DATA, define and populate the CUSTOMER table.

Member ORDRJOB contains the GETORDRS application source and JCL to


preprocess, compile, and linkedit it. The UPDATJOB member contains the
ORUPDATE application source and JCL to preprocess, compile, and linkedit
it.

3.3.5 About WebSphere Application Server configuration


This section describes how we configured WebSphere Application Server to
support the development of our Web application.

3.3.5.1 General information


On ADS V2, we installed WebSphere Application Server 3.02, Service level 3.
In this discussion below, we’ll call it WAS.

WAS runs as a plugin under IBM HTTP Server, the Web server. The
configuration file for the Web server is:
/etc/httpd.conf

The configuration file contains a service directive to route all the URL
requests for this Web application to WAS. The service entry looks like this:
Service /demos/b2bapp/*
/usr/lpp/WebSphere/AppServer/bin/was302plugin.so:service_exit

The primary configuration file for WAS is:


/demos/websphere.cnf

The configuration file includes the host name, IP address, classpath, and
many other settings. To see how we defined this Web application in the
configuration file, see 8.1, “Define a Web application in WebSphere
Application Server” on page 177.

The classpath in the configuration file was set to include the e-connector jars
(which were uploaded from VisualAge for Java), and VisualAge for Java jars.
Table 3 lists the jars that were added to the classpath to support this
application.

Chapter 3. About the server configuration 41


Important: Classpath items are separated by a colon (:) in the classpath
statement.
Table 3. Jars required by our B2B Web application

Feature Jar

CICS Connector /usr/lpp/ctg/classes/ctgclient.jar


/usr/lpp/ctg/classes/ctgserver.jar

Enterprise Access Builder /demos/jars/recjava.jar


/demos/jars/eablib.jar
/demos/jars/imseab.jar

StudioPervasiveServlet class /demos/jars/webtlsrn.jar

VisualAge for Java /demos/jars/ivjdab30.jar


/demos/jars/ivjpb302.jar
/demos/jars/ivjsns20.jar
/demos/jars/ivjsb30.jar
/demos/jars/infobus.jar

IMS Connector /demos/jars/imstoc.jar

MQ Connector /demos/jars/mqccf.jar

3.3.5.2 About servlet definition


We configured the Application Server to find and run individual servlets that
we wanted to test before including them in Web applications placed in the
/demos/servlets directory. This was done by including the following in
websphere.cnf.
deployedwebapp.Our_stuff.host=default_host
deployedwebapp.Our_stuff.rooturi=/
deployedwebapp.Our_stuff.classpath=/demos/servlets
deployedwebapp.Our_stuff.documentroot=/
deployedwebapp.Our_stuff.autoreloadinterval=10000
webapp.Our_stuff.jspmapping=*.jsp
webapp.Our_stuff.jsplevel=.91

By defining this directory, we didn’t have to define individual servlets to the


application server.

3.3.5.3 Setting the classpath


In order to run servlets on the server, it must contain the jar files that your
application requires, and the classpath must reference those jars. As
described above, the ADS system includes the jars required to run most
servlets which use Common Connector Framework e-connectors and were
generated with WebSphere Studio V3.02.

42 Creating an Interactive B2B Web Application


If you are configuring your own server, or are working on ADS and need to
add additional jars to the class path, consult with your system administrator. If
you do have authority to update the classpath yourself, you can follow a
procedure similar to the one we followed:
1. FTP the jars you need to the appropriate directory on your 390 server. For
example, to get the jar we needed for the StudioPervasiveServlet, we
FTP’d <studiopath>\lib\CompileTimeClasses\AppServerV3\webtlsrn.jar
from the Windows client to /demos/jars/ on ADS system.
2. On the SDF main menu, stop WebSphere Application Server. On ADS, we
typed the following, which stops the Web server and WebSphere
Application Server combined process:
/P IMWEBSRV
3. On the OMVS system, edit /demos/websphere.cnf.
Tip: If you are using ADS, and your client is configured to use SMB, you
can edit a copy of the websphere.cnf file using your favorite client text
editor.
4. Add additional jars to the classpath by placing them at the end of the line
that starts:
appserver.classpath=
Important: Separate the files on this list using a colon.
5. Save websphere.cnf.
6. On the SDF main menu, restart WebSphere Application Server. On ADS,
we typed:
/S IMWEBSRV

3.3.6 About IMS Connect


To access the IMS transaction using the IMS Connector for Java (that is
supplied with VisualAge for Java), IMS Connect must be set up on the server.
To learn how to set up IMS Connect, see IMS Connect Guide and Reference,
SC27-0946.

To learn how to use the IMS Connector for Java, see the online help in
VisualAge for Java.

3.3.6.1 Checking the IMS Connect environment


Once IMS Connect is set up, it is a good idea to verify that it is configured
properly and that the address space is running and accepting connections.

Chapter 3. About the server configuration 43


You can verify that it is connected to the datastore using the IMS command
/DIS OTMA. The command output on a properly set up system will look
similar to Figure 21.

IEE600I REPLY TO 38 IS;/DIS OTMA


DFS000I GROUP/MEMBER XCF-STATUS USER-STATUS SECURITY
IMS1
DFS000I IMS61XCF
IMS1
DFS000I -IMS1OTMA ACTIVE SERVER FULL
IMS1
DFS000I -IMS1ITOC ACTIVE ACCEPT TRAFFIC
IMS1
DFS000I *00354/174329* IMS1

Figure 21. IMS: /DIS OTMA command output

Running the IMS Connect command VIEWHWS should produce results


similar to Figure 22.

IEE600I REPLY TO 35 IS;VIEWHWS


HWSC0001I HWS ID=IMS1ITOC Racf=N
*40 HWSC0000I *HWS READY* IMS1ITOC
HWSC0001I Maxsoc=50 Timeout=0
HWSC0001I Datastore=IMS1 Status=ACTIVE
HWSC0001I Group=IMS61XCF Member=IMS1ITOC
HWSC0001I Target Member=IMS1OTMA
HWSC0001I Port=3336 Status=ACTIVE
HWSC0001I No active Clients

Figure 22. IMS Connect: VIEWHWS command output

Record the hostname or IP-address and the port number that IMS Connect is
using. Also, record the Datastore name to connect to the right IMS System.
These parameters are used later when you create the Java code that
accesses the IMS transaction.

44 Creating an Interactive B2B Web Application


Part 2. Creating the servlets

This part walks you through detailed steps to create the four servlets that
provide the foundation for the Web application. You use VisualAge for Java
and WebSphere Studio to develop the servlets. Then, you deploy them to
WebSphere Application Server on OS/390.

© Copyright IBM Corp. 2001 45


46 Creating an Interactive B2B Web Application
Chapter 4. Create the order servlet

In this chapter, you create the order servlet, which, in conjunction with several
server applications:
• Provides a Web page for customers to start the application
• Gets the customer number that the user enters on the Web page
• Retrieves customer and order information from the server
• Formats and displays the customer and order information in the Web
browser

The order servlet uses the CICS Connector to connect to CICS Transaction
Gateway (CTG) on 390. CTG passes along the request data provided with the
connector to the CICS server. The server runs two COBOL/CICS/ECI
applications, V2CSTDB and GETORDRS, to retrieve data from two DB2
tables, CUSTOMER and ORDERS, respectively. CTG returns the data to the
order servlet, which formats and displays the it in the Web browser.

When you create the order servlet, you follow the same steps as you would if
you created your own servlet to access CICS and DB2.
1. Create Java beans that access CICS and DB2.
2. Test the CICS connection, using a Java application.
3. Generate the order servlet and generic user interface files.
4. Customize the generated servlet.
5. Publish the order servlet on the test stage.
6. Test the order servlet in the WebSphere Test Environment.
7. Modify the order beans for publishing on the server.
8. Publish the order servlet on the server.
9. Test the order servlet from a Web browser.

4.1 Create Java beans that access CICS and DB2


In this section, you create Java beans to access CICS applications on the
server. These beans will be used by the order servlet.

In general terms, you use the Enterprise Access Builder COBOL Record
Generator feature to create a record type and record, so that you can access
the V2CSTDB and GETORDRS programs installed in CICS on 390. You

© Copyright IBM Corp. 2001 47


create command classes to run the programs and a navigator to manage the
flow of execution.

Specifically, to create the beans, you:


1. Create the B2BApp project.
2. Create the order package.
3. Create the COBOL customer record type.
4. Create the CustomerRecord class.
5. Create the COBOL order record type.
6. Create the OrderRecord class.
7. Create the RetrieveCustomerCommand class.
8. Create the RetrieveOrderCommand class.
9. Create the CICSRetrieveNavigator class.

4.1.1 Create the B2BApp project


You create the servlets as individual packages under a single project called
B2BApp.
1. Open VisualAge for Java.
2. Click File -> QuickStart -> Basic -> Create Project and click OK.
3. Type B2BApp as the Project name and click Finish. B2BApp is added to the
Workbench Projects list.

4.1.2 Create the order package


You create the order package to contain the classes that retrieve the
customer and order information.
1. Right-click B2BApp and click Add -> Package.
2. Type order as the package name.
3. Click Finish.

4.1.3 Create the COBOL customer record type


Next, you create the CustomerRecordType class, which specifies the
customer information available from the COBOL CICS program V2CSTDB.
This information includes the customer's number, name, and shipping
address.
1. In the Workbench, right-click the order package.

48 Creating an Interactive B2B Web Application


2. Click Tools -> Enterprise Access Builder -> Import COBOL to Record
Type.
3. In the Import COBOL to Record Type window, click Browse.
4. Find V2CSTDB.ccp, located in the \client\cobol directory where you
installed the demo files, and click Open.
5. Click Next. The SmartGuide selects DFHCOMMAREA fromV2CSTDB as
the default commarea to import. Keep the selection.
6. Click Next again.
7. In the Class Name field, type CustomerRecordType.
8. Click Finish. The CustomerRecordType class is added to the order
package and the Create Record from RecordType SmartGuide opens.

4.1.4 Create the CustomerRecord class


You create a CustomerRecord class, of type CustomerRecordType, to hold
the customer information.
1. In the Class name field of Create Record from RecordType SmartGuide,
type CustomerRecord.
2. Set the options shown in Table 4.
Table 4. CustomerRecord generation options

Generation option Selection

Access Method Direct


Record Style Custom Records
Additional Options Generate with Notification

3. Click Next.
4. Specify the properties shown in Table 5 for the record attributes.
Table 5. CustomerRecord record attributes

Property Value

Floating Point Format IBM


Endian Big Endian
Remote Integer Endian Big Endian
Code Page 8859_1
Machine Type MVS

Chapter 4. Create the order servlet 49


5. Click Finish.

The entries for the B2BApp should look similar to this for your workspace.
However, your names will follow your own naming convention.

4.1.5 Create the COBOL order record type


In this step you create the OrderRecordType class, which specifies the order
information available from the COBOL program GETORDRS. This information
includes the customer's number, item number, item description, shipping
date, shipping cost, and shipper.
1. In the Workbench, right-click the order package.
2. Click Tools -> Enterprise Access Builder -> Import COBOL to Record
Type.
3. Click Browse and find the getordrs.ccp file, located in the \client\cobol
directory where you installed the demo files, and click Open.
If you examine getordrs.ccp, you will see that it is imbedded in JCL. This is
because the GETORDRS source code is in the ORDRJOB member in
DEMOS.MQB2B.JCL on ADS. It was included in the demo files by
downloaded it from the ADS and including it in the demos.zip file.
4. Click Next.
5. Click Next on the Commarea selection page.
6. In the Class Name field, type OrderRecordType.
7. Click Finish. The OrderRecordType class is added to the B2BApp
package and the Create Record from RecordType SmartGuide opens.

4.1.6 Create the OrderRecord class


You create an OrderRecord class, of type OrderRecordType, to hold the order
information.
1. In the Class name field of Create Record from RecordType SmartGuide,
type OrderRecord.
2. Set the options shown in Table 6.
Table 6. OrderRecord generation options

Generation option Selection

Access Method Direct


Record Style Custom Records
Additional Options Generate with Notification

50 Creating an Interactive B2B Web Application


3. Click Next.
4. Specify the properties shown in Table 7.
Table 7. OrderRecord record attributes

Property Value

Floating Point Format IBM


Endian Big Endian
Remote Integer Endian Big Endian
Code Page 8859_1
Machine Type MVS

5. Click Finish.

4.1.7 Create the RetrieveCustomerCommand class


Next you create a command class to connect to CICS and interact with the
COBOL CICS application V2CSTDB. You use classes provided by the CICS
Connector and the IBM Common Connector Framework features to define the
command class.

4.1.7.1 Define the class


1. In the Workbench, right-click the order package.
2. From the menu for the package, click Tools -> Enterprise Access
Builder -> Create Command. The Create Command SmartGuide opens.
3. In the Class name field, type RetrieveCustomerCommand.
4. Click Browse beside the Connection Spec class name field.
5. From the class selection box, select CICSConnectionSpec, and click OK.
6. Click Browse beside the Interaction Spec class name field.
7. From the class selection box, select ECIInteractionSpec, and click OK.
The window should look similar to Figure 23.

Chapter 4. Create the order servlet 51


Figure 23. RetrieveCustomerCommand class definition

8. Click Next.

4.1.7.2 Define the bean to be used for input and output


1. Make sure that Implements IByteBuffer is selected.
2. Click the Browse button beside the Input record bean Class name field.
3. From the class selection box, select CustomerRecord in the order
package, and click OK.
4. Click Use input bean as output so you only have to define bean for both
input and output.
5. Click Finish. The Command Editor window opens.

52 Creating an Interactive B2B Web Application


4.1.7.3 Customize the connections for your server
1. In the Command Editor window, select the Connector folder in the top left
pane, and then select com.ibm.connector.cics.CICSConnectionSpec in
the top right pane.
2. In the properties table in the bottom pane, specify the properties listed in
Table 8, pressing Enter after each addition.
Table 8. RetrieveCustomerCommand ConnectionSpec properties

Property Value

URL Host name or IP address for the machine where the CICS
Transaction Gateway is running. For ADS, type the IP address of
your ADS server. For example, 9.117.142.111

CICSServer A06C001, the host name of the target CICS server on which the
transactions reside. This is the VTAM NetID of the CICS Demo
Region on the ADS server. The host name is used by the CICS client,
to communicate with the CICS server.

The window should look similar to Figure 24, except that it will have the IP
address of your ADS server as the value of the URL property.

Chapter 4. Create the order servlet 53


Figure 24. RetreiveCustomerCommand ConnectionSpec properties

3. Select com.ibm.connector.cics.ECIInteractionSpec in the top right


pane.
4. In the properties table in the bottom pane, specify the properties listed in
Table 9, pressing Enter after each change.
Table 9. RetrieveCustomerCommand InteractionSpec properties

Property Value

ProgramName V2CSTDB, the name of the CICS program you want to run. In
this case, it is the program that retrieves customer data from
the DB2 CUSTOMER table.

TPNTransactionName True, which indicates you want to attach a transaction to it.

TransactionName CPMI, a mirror transaction that handles conversions between


EBCDIC and ASCII.
Tip: You use CPMI for the workstation version of the code.
You use a different transaction when you move the code to the
host, because no conversion is required. See 4.7, “Modify the
order beans for publishing on the server” on page 81.

54 Creating an Interactive B2B Web Application


The window should look similar to Figure 25.

Figure 25. RetreiveCustomerCommand InteractionSpec properties

4.1.7.4 Specify the input properties


In this step you create properties for each of the fields you want to send
through CICS to V2CSTDB as input.
1. In the Command Editor window, select the Input folder in the top left pane,
and then select the order.CustomerRecord bean in the top right pane.
2. In the properties table in the bottom pane, right-click the CUSTNO
property and click Promote Property.
3. Right-click the CUSTNO property again, and click Change Promote
Name.
4. Change the name to inCUSTNO.

The window should look similar to Figure 26.

Chapter 4. Create the order servlet 55


Figure 26. RetrieveCustomerCommand, CustomerRecord input bean properties

4.1.7.5 Specify the output properties


In these steps, you specify those fields you want returned from V2CSTDB by
CICS:
1. In the Command Editor window, select the Output folder in the top left
pane, and then select order.CustomerRecord in the top right pane.
2. Select all of the properties listed in Table 10.
3. Right-click and click Promote Property.
4. Right-click each property again and click Change Promote Name.
5. Add output to the beginning of each field name.
Table 10. CustomerRecord output bean properties

Property Promoted property name

CUSTNO outputCUSTNO

STATE outputSTATE

56 Creating an Interactive B2B Web Application


Property Promoted property name

ADDRESS1 outputADDRESS1

COUNTRY outputCOUNTRY

CITY outputCITY

FIRSTNAME outputFIRSTNAME

LASTNAME outputLASTNAME

6. Click Command -> Save to save your changes.


7. Click Command -> Exit Editor to close the Command Editor.

The contents of the package should like Figure 27.

Figure 27. Order package, with first Command bean, RetrieveCustomerCommand

4.1.8 Create the RetrieveOrderCommand class


Next you create a second command class to connect to CICS. This bean will
interact with the COBOL CICS application, GETORDRS, to retrieve the
customer’s order information.

4.1.8.1 Define the class


1. In the Workbench, right-click the order package.
2. Click Tools -> Enterprise Access Builder -> Create Command. The
Create Command SmartGuide opens.
3. In the Class name field, type RetrieveOrderCommand.
4. Click Browse beside the Connection Spec class name field.
5. From the class selection box, select CICSConnectionSpec, and click OK.
6. Click Browse beside the Interaction Spec class name field.
7. From the class selection box, select ECIInteractionSpec, and click OK.

Chapter 4. Create the order servlet 57


8. Click Next.

4.1.8.2 Define a bean to use for input and output


1. Make sure that the Implements IByteBuffer check box is selected.
2. Click the Browse button beside the Input record bean class name field.
3. From the class selection box, select OrderRecord in the order package,
and click OK.
4. Click Use input bean as output.
5. Click Finish. The Command Editor window opens.

4.1.8.3 Customize the connections for your server


1. In the Command Editor window, select the Connector folder, and the
CICSConnectionSpec bean in the top panes.
2. Specify the properties listed in Table 11, pressing Enter after each
addition.
Table 11. RetrieveOrderCommand ConnectionSpec properties

Property Value

URL Host name or IP address for the machine where the CICS
Transaction Gateway is running. For ADS, type ADSYSTEM or the IP
address of your ADS server; for example, 9.117.142.111

CICSServer A06C001, the host name of the target CICS server on which the
transactions reside. This is the VTAM NetID of the CICS Demo
Region on the ADS server.

3. In the top right pane, select the ECIInteractionSpec bean.

58 Creating an Interactive B2B Web Application


4. In the properties table, specify the properties listed in Table 12, pressing
Enter after each addition.
Table 12. RetrieveOrderCommand InteractionSpec properties

Property Value

ProgramName GETORDRS, the member name in DEMO.CICS.LOAD, for the


program that runs in the CICS server. Retrieves order
information from the ORDER table.

TPNTransactionName True, to indicate you want to attach a transaction to it.

TransactionName MQCP, which references a clone of DFHMIR, called


DFHMIRRS, a mirror transaction that handles conversions
between EBCDIC and ASCII. The clone is required because
we used CPMI for V2CSTDB, which is in a different group.
Tip: You use MQCP for the workstation version of the code.
You use a different transaction when you move the code to the
host, because no conversion is required. See 4.7, “Modify the
order beans for publishing on the server” on page 81.

4.1.8.4 Specify the input properties


In this section, you create properties for each field you want to pass to the
GETORDRS program to use as input:
1. In the Command Editor window, select the Input folder, and then select
order.OrderRecord.
2. In the properties table, right-click the CCUSTNO property.
3. From the menu for the property, click Promote Property.
4. Right-click the CCUSTNO property again, and click Change Promote
Name.
5. Change the name to inputCCUSTNO.

4.1.8.5 Specify the output properties


In this step, you create properties for each returned field you want to access
from GETORDRS.
1. In the Command Editor window, select the Output folder, and then select
order.OrderRecord bean.
2. On the Property menu, de-select Show All Properties.
3. In the properties table in the bottom pane, select all of the properties in the
list. (Click the first one, hold the Shift key and click the last one).
4. Right-click and click Promote Property.

Chapter 4. Create the order servlet 59


5. Right-click each property and click Change Promote Name.
6. Add output to the beginning of each field name as shown in Table 13.
Table 13. Output properties for RetrieveOrderCommand

Property Promoted property name

CCUSTNO outputCCUSTNO

CITEM outputCITEM

CITEMNO outputCITEMNO

CITEMCST outputCITEMCST

CSHPDATE outputCSHPDATE

CSHPPER outputCSHPPER

CSHPCOST outputCSHPCOST

7. Click Command -> Save to save your changes.


8. Click Command -> Exit Editor to close the Command Editor.

The contents of the package should look similar to Figure 28.

Figure 28. Order package contents, including both Command beans

4.1.9 Create the CICSRetrieveNavigator class


In this step you create a class known as a navigator (in Common Connector
Framework terminology) to manage a sequence of requests to CICS (in this
case, using ECI). You use the navigator to run RetrieveCustomerCommand
and RetrieveOrderCommand as a single logical unit of work.

4.1.9.1 Create the class


1. Right-click the order package, and click Add -> Class.

60 Creating an Interactive B2B Web Application


2. In the Create a new class field, type CICSRetrieveNavigator.
3. To the right of the Superclass field, click Browse.
4. Select CommunicationNavigator type in the com.ibm.ivj.eab.command
package, and click OK.
5. Click Finish. The VisualComposition Editor opens.

4.1.9.2 Define the properties


Now you define properties for all the data fields that you need to access in the
navigator class:
1. On the BeanInfo page of CICSRetrieveNavigator, right-click in the
Features pane, and click New Property Feature.
2. In the Property name field, type customerNumber.
3. From the Property type list, select int.
Tip: Be sure to select int, not int[].
4. Make sure these options are selected: Readable, Writeable, and bound.
5. Click Finish.
6. Using the same options, add more properties, using the names and types
specified in Table 14.
Table 14. CICSRetrieveNavigator properties
Property name Property type
customerNumber int (Do not select int[].)
customerFirstName java.lang.String
customerLastName java.lang.String
customerAddress java.lang.String
customerCity java.lang.String
customerState java.lang.String
customerCountry java.lang.String
orderItem java.lang.String
orderItemNumber int (Do not select int[].)
orderItemCost double
orderShipper java.lang.String
orderShipDate java.lang.String
orderShipCost double

Chapter 4. Create the order servlet 61


The BeanInfo window should look similar to Figure .

Figure 29. CICSRetrieveNavigator properties on the BeanInfo page

4.1.9.3 Instantiate the beans


To define the program execution flow and transfer of data, you add instances
of the RetrieveCustomerCommand, RetrieveOrderCommand, and the
CICSConnectionSpec beans to the navigator.
1. On the Visual Composition page of CICSRetrieveNavigator, click the
Choose Bean icon in the toolbox, and then click Browse.
2. Select RetrieveCustomerComannd in the order package and click OK.
3. In the Name field, type customer.
4. Drop the customer bean onto the free-form surface of
CICSRetrieveNavigator.

62 Creating an Interactive B2B Web Application


5. Following the same procedure, choose the
order.RetrieveOrderCommand bean, name it order, and drop it onto
CICSRetrieveNavigator.
6. Finally, choose the com.ibm.connector.cics.CICSConnectionSpec
bean, name it NavCICSConnection, and drop it onto CICSRetrieveNavigator.

4.1.9.4 Make the property-to-property connections


Next, you make property-to-property connections among the navigator
properties and these command and connection spec bean properties.
VisualAge for Java uses the connections to generate the code to retrieve the
customer and order information.

To make each property-to-property connection, listed in Table 15:


1. Right-click the first object (for example, the customer object), and then
click Connect -> Connectable Features.
Important: Be sure that the Property (not Event) option is selected.
2. Select the property for that object (for example, inCUSTNO), and click OK.
3. Draw the line to the second object. For CICSRetrieveNavigator, draw it to
a blank area on the free-form surface.
4. Click and then select Connectable Features.
5. Select the property in the second object (for example, customerNumber),
and click OK. The connection displays as a green line on the
CICSRetrieveNavigator.
Table 15. Property-to-property connections for CICSRetrieveNavigator

First object Property Second object Property

customer inputCUSTNO CICSRetrieveNavigator customerNumber

customer outputFIRSTNAME CICSRetrieveNavigator customerFirstName

customer outputLASTNAME CICSRetrieveNavigator customerLastName

customer outputADDRESS1 CICSRetrieveNavigator customerAddress

customer outputCITY CICSRetrieveNavigator customerCity

customer outputSTATE CICSRetrieveNavigator customerState

customer outputCOUNTRY CICSRetrieveNavigator customerCountry

order outputCITEMNO CICSRetrieveNavigator orderItemNumber

order outputCITEM CICSRetrieveNavigator orderItem

Chapter 4. Create the order servlet 63


First object Property Second object Property

order outputCITEMCST CICSRetrieveNavigator orderItemCost

order outputCSHIPPER CICSRetrieveNavigator orderShipper

order outputCSHPDATE CICSRetrieveNavigator orderShipDate

order outputCSHPCOST CICSRetrieveNavigator orderShipCost

customer inputCUSTNO order inputCCUSTNO

NavCICSConnection this CICSRetrieveNavigator connectionSpec

CICSRetrieveNavigator should now look similar to Figure 30.

Figure 30. CICSRetrieveNavigator with property-to-property connections

4.1.9.5 Make the event-to-method connections


Next you define connections between events that occur and the code you
want to execute when the events occur (that is, the event-to-method
connections).

To make each event-to-method connection shown in Table 16:


1. Right-click the first object, and then click Connect -> Connectable
Features. For CICSRetrieveNavigator, right-click on an empty spot of the
free-form surface.
Important: Make sure the Event (not Property) option is selected.
2. Select the event for the first object, and click OK.

64 Creating an Interactive B2B Web Application


3. Draw the line to the second object.
4. Click, and then select Connectable Features.
Important: Make sure the Method option is selected.
5. Select the method in the second object, and click OK. The connection
displays on the CICSRetrieveNavigator.
6. Double-click the connection, select Pass Event Data, and click OK.
Tip: If the connection appears as a dashed line, you probably forgot to do
this last step.
Table 16. Event-to-method connections for CICSRetrieveNavigator

First object Event Second object Method

CICSRetrieveNavigator internalExecutionStarting customer execute (com.ibm


.ivj.eab.command.
CommandEvent)

customer executionUnsuccessful com.ibm.ivj.eab. CICSRetrieve


command.CommandEvent Navigator

customer executionSuccessful order execute (com.ibm.


ivj.eab.command.
CommandEvent)

order executionUnsuccessful CICSRetrieveNavigator returnExecution


Unsuccessful
(com.ibm.ivj.eab.
command.
CommandEvent)

order executionSuccessful CICSRetrieveNavigator returnExecution


Successful
(com.ibm.ivj.eab.
command.
CommandEvent)

CICSRetrieveNavigator should look similar to Figure 31.

Chapter 4. Create the order servlet 65


Figure 31. All connections in CICSRetrieveNavigator

4.1.9.6 Set the ConnectionSpec properties


Finally, set the following properties on the NavConnectionsSpec object so
that the object can find the CICS Server.
1. Right-click the NavCICSConnection object, and click Properties.
2. Set the properties listed in Table 17.
Table 17. NavCICSConnection properties

Property Value

URL Host name or IP address for the machine where the CICS
Transaction Gateway is running. For ADS, type the IP address of your
ADS server. For example, 9.117.142.111.

CICSServer A06C001, the host name of the target CICS server on which the
transactions reside. This is the VTAM NetID of the CICS Demo
Region on the ADS server. The host name is used by the CICS client,
to communicate with the CICS server.

3. Click Bean -> Save Bean to save CICSRetrieveNavigator.


4. Close the Visual Composition Editor window.

You have completed creating the beans that access CICS and DB2.

66 Creating an Interactive B2B Web Application


4.2 Test the CICS connection
The classes that you have created so far will be used to generate the servlet.
However, before you generate the servlet, it is a good idea to test the
connection to CICS. You need a class to start the navigator.

4.2.1 Create a CICSNavExecute test application


In this step, you add a test application (a class with a main method) to the
order package and supply some Java code to execute the navigator.

4.2.1.1 Define the class


1. In the Workbench, right-click the order package, and click Add -> Class.
The Create Class SmartGuide opens.
2. In the Class name field, type CICSNavExecute
3. Leave the SuperClass as the default, java.lang.Object.
4. Click Next.

4.2.1.2 Add the connector import statements


1. Click Add Package. The Import statement window opens.
2. Select com.ibm.connector.infrastructure and click Add.
3. Select com.ibm.connector.infrastructure.java and click Add.
4. Click Close in the Import statement window.

4.2.1.3 Create the main method


1. On the Attributes page of the SmartGuide, make sure the public modifier
is selected.
2. Make sure the following settings are selected:
Methods which must be implemented (Recommended)
Copy constructors from superclass (Recommended)
3. Select main(String[]).
4. Click Finish. The CICS NavExecute class is added to the order package in
the Workbench window.

4.2.1.4 Add the code to execute the navigator class


1. In the CICS NavExecute class, double-click the main(String[]) method.
2. Replace the code with the code in Figure 32.

Chapter 4. Create the order servlet 67


public static void main(java.lang.String[] args) {
// code for testing navigator before creating servlet
int customerNumber = 3;
com.ibm.connector.infrastructure.java.
JavaRuntimeContext runtimeContext = new com.ibm.connector.
infrastructure.java.JavaRuntimeContext();

System.out.println("Created New Runtime Context");


((com.ibm.connector.infrastructure.DefaultLogonInfo)runtimeContext.
getLogonInfo()).setUser("");
((com.ibm.connector.infrastructure.DefaultLogonInfo)runtimeContext.
getLogonInfo()).setPassword("");
com.ibm.connector.infrastructure.java.JavaRuntimeContext.
setCurrent(runtimeContext);

CICSRetrieveNavigator cnav = new CICSRetrieveNavigator();


System.out.println("Created new CICSRetrieveNavigator");

cnav.setCustomerNumber(customerNumber) ;

cnav.execute(new com.ibm.ivj.eab.command.
CommandEvent(cnav));

System.out.println("Executed cnav");
System.out.println("Customer number = " + cnav.getCustomerNumber());
System.out.println("Firstname = " + cnav.getCustomerFirstName());
System.out.println("Last name = " + cnav.getCustomerLastName());
System.out.println("Address = " + cnav.getCustomerAddress());
System.out.println("City = " + cnav.getCustomerCity());
System.out.println("State = " + cnav.getCustomerState());
System.out.println("Country = " + cnav.getCustomerCountry());
System.out.println("Order item = " + cnav.getOrderItem());
System.out.println("Item number = " + cnav.getOrderItemNumber());
System.out.println("Item cost= " + cnav.getOrderItemCost());
System.out.println("Shipper = " + cnav.getOrderShipper());
System.out.println("Ship cost = " + cnav.getOrderShipCost());
System.out.println("Ship date = " + cnav.getOrderShipDate());
((com.ibm.connector.infrastructure.java.JavaCoordinator)
runtimeContext.getCoordinator()).commit();
runtimeContext.close();
return;
}

Figure 32. CICSNavExecute main method for testing the order beans

68 Creating an Interactive B2B Web Application


Tip: In a production environment, you would need to specify a userid and
password. The ADS machine does not require a user ID and password to
get into CICS so none is specified here.
3. Click Edit -> Save.

Tip: To display information on the Java Console while your program is


running, put System.out.println statements in your program following the
examples in the above code.

The order package should look similar to Figure 33.

Figure 33. Order package, containing all the beans and a test application

4.2.2 Run the CICSNavExecute test


In this step you run the test application to see if the navigator can connect to
CICS.
1. Right-click the CICSNavExecute class, and click Run -> Check Class
Path.
2. Click Compute Now.
3. When processing is complete, click OK.
4. Right-click the CICSNavExecute class again, and click Run -> Run Main.

The Console window opens with the result that should look similar Figure 34.

Chapter 4. Create the order servlet 69


Figure 34. VisualAge for Java Console with CICSNaveExecute results

4.2.3 What you have proved so far


Now you know that your order beans can connect to CICS and retrieve the
data from both the CUSTOMER and ORDERS tables in DB2!

In the test application, CICSNavExecute, you hard-coded a customer number


to pass as the input property to the navigator. The navigator used its
ConnectionSpec bean to connect to CICS, then used the Command beans to
retrieve the data. The information was retrieved from the CUSTOMER table
and the ORDERS table, using the COBOL CICS applications V2CSTDB and
GETORDRS, that you specified in the InteractionSpecs of your Command
beans.

70 Creating an Interactive B2B Web Application


4.2.4 Create a version of the order package
It is a good idea to save what you have done so far as a version of the
package. Later in this tutorial, you will build on this package to create the host
version, but you might want to look at or work with the workstation-only
package on another project.

To create a version:
1. Right-click the order package and click Manage -> Version.
2. Select the Automatic option, and click OK.

To create a new edition that you can work in later for the host version:
1. Right-click the order package again, and click Manage -> Create Open
Edition.
2. Click OK.

You have a new edition in which to work on the host version.

4.3 Generate the order servlet and generic user interface files
In this section you create a new Java class, the order servlet, which will:
1. Manage the interaction with the customer
2. Call the order beans you just created
3. Compile the result data with the JSP to display the results

4.3.1 Preparing the WebSphere Studio project


In this sequence, you create a Studio project, export the bean classes from
VisualAge for Java into that project, and then customize the project for your
target server.

4.3.1.1 Create the B2BApp Project in Studio


1. To open WebSphere Studio, on the Windows task bar, click Start ->
Programs -> IBM WebSphere Studio -> Studio 3.5 -> IBM WebSphere
Studio V3.5.
2. Create a new project called B2BApp.
If this is the first time that you have opened Studio, it will prompt you for a
new project name using the Default Template. If you have already created
other projects, you can create the B2BApp project by clicking File -> New
Project.

Chapter 4. Create the order servlet 71


3. On the New Project window, click Browse to the right of the Project Folder
field.
4. Find the drive and directory where you installed Studio, select the projects
folder, and add the project name to the path.
<studiopath>\projects\B2BApp\
Studio generates the B2BApp folder under the projects directory and
initializes the B2bApp project.

4.3.1.2 Export the order package from VisualAge for Java to Studio
To export the order package for use by WebSphere Studio:
1. In VisualAge for Java, select the order package, and click File -> Export.
2. Select Directory and click Next.
3. Click Browse and find the servlet directory under the B2BApp project (in
WebSphere Studio) that you just created. For example:
<studiopath>\projects\B2BApp\servlet\
4. Click OK.
5. Select the .class and .java check boxes.
6. Click Finish.

4.3.1.3 Add the order package to the B2BApp Studio project


1. Under B2BApp, right-click the servlet folder, and click Insert -> Folder.
2. In the Insert Folder window, click the Use Existing tab.
3. Click Browse.
4. Find <studiopath>\projects\B2BApp\servlet\order and click OK.
5. Click OK in the Insert Folder window.

To remove the read-only attributes from the files:


1. In Windows NT Explorer, select all the files in the
<studiopath>\projects\B2BApp\servlet\order directory.
Tip: Press Ctrl+A to select all the files.
2. Right-click one of the selected files, and select Properties.
3. Clear the Read-only check box, and click OK.

4.3.1.4 Set the B2BApp Studio project properties


In this task, you customize the project properties so you can create servlets
that can be deployed on WebSphere Application Server.

72 Creating an Interactive B2B Web Application


1. In WebSphere Studio, right-click the B2BApp project and click
Properties.
2. On the Advanced page, set the properties as shown in Table 18.
Table 18. Studio project properties for WebSphere Application Server

Property WAS 3.02

Application Server version 3.0

JSP version 1.0

Code Generation style ServletModel

Compile-time classes AppServerV3

Mark-up languages HTML

3. Click OK to close the Properties window.

4.3.1.5 Add resource files to the Studio project


Next, you make the Common Connector Framework and some of the
connector classes available for Studio to compile Java code.
1. In the left pane, right-click resources and click Insert -> File.
2. On the Use Existing tab, click the Browse button, find the files in the
<drive:>\IBM Connectors\classes directory listed below, and then click
Open.
Tip: You can select more than one file in a directory by holding down the
Ctrl key and selecting each of the files. The IBM Connectors directory is
usually on the same drive as VisualAge for Java, on your Windows
machine.
3. Click OK on the Insert File window.
4. Repeat this procedure for the files in the <vajpath>\eab directory listed in
Table 19.
Table 19. Connector related jars required to compile

File Location

ccf.jar <drive:>\IBM Connectors\classes

imsconn.jar <drive:>\IBM Connectors\classes


(IMS Connector, for email servlet)

mqccf.jar <drive:>\IBM Connectors\classes


(MQ Connector, for bid and accept servlets)

Chapter 4. Create the order servlet 73


4.3.2 Generate the order servlet, HTML, and JSP files
Now, you use the JavaBean Wizard in Studio to create a servlet file and
generic user interface files.
1. Select B2BApp and click Tools -> Wizards -> JavaBean Wizard.
2. From the menu select the ...\CICSRetrieveNavigator.class.
The JavaBean name should read: order.CICSRetrieveNavigator
3. Click Next.
4. Make sure ServletModel is selected in the style of code list and HTML is
selected as the Markup Language; then click Next.
5. Select Create a page for when an error occurs. The input page and
results page should already be selected; leave them selected.
6. Click Next.
7. On the Input Page select customerNumber.
This is the only property we need for the user on the input Web page.
8. Click OK.
9. Click Next.

To specify the properties that you want on the results page (the page that
displays the customer and order information).
1. On the Results Page window, select these variables and use the arrow
keys on the right to arrange them in this order:
customerFirstName
customerLastName
customerNumber
customerAddress
customerCity
customerState
customerCountry
orderItemNumber
orderItem
orderItemCost
orderShipDate
orderShipCost

74 Creating an Interactive B2B Web Application


orderShipper
2. Click Next.
3. On the Standard Error Page, click Next.

To complete the servlet specifications:


1. On the Methods page, select the method that the servlet will run to start
the CICSRetrieveNavigator:
execute(com.ibm.ivj.eab.command.CommandEvent)
2. Click Next.
3. On the Session page, click Yes, store it in the user’s session.
4. Type custorder for the bean name, and click Next.
5. On the Finish page, click Rename.
6. In the Package Name field, type general.
7. In the Prefix field, type custorder.
8. Click OK.
9. Click Finish.

WebSphere generates the files in Table 20. A message displays telling you to
edit and modify one of the generated files for input parameters, which you do
next.
Table 20. Files generated by WebSphere Studio for order servlet

Generated file Folder Purpose

custorder.java servlet\general Servlet source

custorder.class servlet\general Compiled servlet

custorder.servlet servlet\general Servlet configuration file

custorderHTMLInput.html B2BApp Initial user interface

custorderHTMLResults.jsp B2BApp Used by servlet to display results when


processing runs correctly

custorderHTMLError.jsp B2BApp Used by servlet to display results when


processing does not run correctly

Chapter 4. Create the order servlet 75


4.4 Customize the order servlet
Now you customize the generated servlet class to execute your order
navigator bean.
1. Open B2BApp -> servlet -> general.
2. Select custorder.java and custorder.class, then right-click and click
Check Out.
3. Double-click custorder.java to open the file in your default editor.
4. Find the lines:
// The following line is commented so the user can manually edit the
code and type the parameters.
// custorder.execute(com.ibm.ivj.eab.command.CommandEvent);
5. Change the second line to:
custorder.execute
(new com.ibm.ivj.eab.command.CommandEvent(custorder));
Important: Be sure to remove the // at the beginning of the line.
6. Save custorder.java and close your editor.
7. To compile the modified file, right-click custorder.java, and click Compile.
A warning message displays asking whether to replace the class file.
8. Click Yes.
9. Select custorder.java and custorder.class, then right-click and click
Check In.

4.5 Publish the order servlet on the test stage


In this sequence you set up a local test environment so you can test your
servlet before publishing it on WebSphere Application Server. The
environment maps to the WebSphere Test Environment, which is a feature of
VisualAge for Java, on your own NT client. This feature provides a local Web
server and servlet engine, which we will refer to as the local test stage.

4.5.1 Set up Studio publishing for local testing


These instructions assume you have never set up Studio to map to the local
test stage. If you have done this previously, skip to 4.5, “Publish the order
servlet on the test stage” on page 76.

76 Creating an Interactive B2B Web Application


To set up the publishing environment, in WebSphere Studio:
1. Click Project -> Publishing Stage -> Test.
2. Click View -> Publishing.
3. Right-click localhost and select Properties.
4. On the Publishing page, select Windows NT in the File system publish
list.
5. Click Define Targets.
6. Select the html publishing target, click Browse, find the following, and
click OK.
<vajpath>\ide\project_resources\IBM WebSphere Test Environment\
hosts\default_host\default_app\web
7. Select the servlet publishing target, click Browse, find the following, and
click OK.
<vajpath>\ide\project_resources\IBM WebSphere Test Environment\
hosts\default_host\default_app\servlets
8. Click OK on the Publishing Targets window.
9. Click OK on the localhost Properties window.

4.5.2 Publish the order files on the test stage


Now you publish the order servlet and its associated HTML and JSP files.
1. In the right pane, right-click the root directory of the publishing path (that
is, click Test), and click Publish whole Project.
Because the order package is the only package in the project so far, you
can publish the whole project.
2. Click OK for Publishing Options.
3. Click OK for Files to Publish.
4. Click Yes on all windows asking if it is OK to publish the file. At the end of
publication, a Publish Report displays in your default Web browser.
5. Close the Web browser and exit from WebSphere Studio.

You can see the files that were published, by opening:


<vajpath>\ide\project_resources\IBM WebSphere Test Environment\
hosts\default_host\default_app\

Look in the servlets\order for your Java beans and in servlets\general for the
servlet. Look in the Web directory for the .html and .jsp files.

Chapter 4. Create the order servlet 77


4.6 Test the order servlet in the WebSphere Test Environment
You use the VisualAge for Java WebSphere Test Environment as the local test
publishing stage to test your servlet before you publish it on WebSphere
Application Server.

You set up the Servlet Engine classpath, start the Servlet Engine, and then
open your input html page in a Web browser.

4.6.1 Set up the Servlet Engine classpath


In the VisualAge for Java Workbench window:
1. Select the IBM WebSphere Test Environment project, and then click
Selected -> Go To -> Type.
2. Type SERunner.
3. Right-click SERunner and click Run -> Check Class Path.
4. To the right of the Project path field, click Edit.
5. Click the Select all button to choose all the projects in your workspace.
6. Scan the list of projects and make sure that the B2BApp project is not
selected. You want to make sure you run the published servlet code, not
the beans inside the development environment.
7. Click OK to close the Class Path window. The class path is updated to
include everything that you selected.
8. To the right of the Extra directories path field, click Edit.
9. Click Add Directory and select the servlet folder that you specified in the
publishing step above. Then add \order to the end of that path:
<vajpath>\ide\project_resources\IBM WebSphere Test Environment\hosts\
default_host\default_app\servlets\order\
10.Click Add Directory and select the servlet folder that you specified in the
publishing step above. Then add \general to the end of that path:
<vajpath>\ide\project_resources\IBM WebSphere Test Environment\hosts\
default_host\default_app\servlets\general\
11.Click OK on all windows until you get out of the Class Path window.

4.6.2 Run the Servlet Engine


To run the Servlet Engine:
1. Right-click SERunner, and click Run -> Run main.

78 Creating an Interactive B2B Web Application


Alternatively, click Workspace->Tools-> Launch WebSphere Test
Environment.
2. Wait for the small WebSphere Test Environment window (Figure 35) and
the Java Console window (Figure 36) to open.

Figure 35. WebSphere Test Environment window

Figure 36. Java console in VisualAge for Java

Chapter 4. Create the order servlet 79


3. Wait until the console messages stop.

4.6.3 Run the servlet


To run the servlet:
1. In the Location or Address field of your Web browser, type:
http://localhost:8080/custorderHTMLInput.html
2. The input page of the servlet opens. The browser should look similar to
Figure 37.

Figure 37. Order servlet input page, in WebSphere Test Environment

3. Type 1 in the customerNumber field, and click Submit.


The order servlet runs and displays the results page, with the customer
and order information, similar to Figure 38.

80 Creating an Interactive B2B Web Application


Figure 38. Order servlet results page, in WebSphere Test Environment

4. To try another customer number (between 1 and 5, inclusive), click Back


on your browser or re-enter the original input Web address.

You are finished with WebSphere Test Environment for now, so you can stop
it.
1. Click Stop and Exit on on the WTE window.
2. Close the Console window.

4.7 Modify the order beans for publishing on the server


When you developed the beans and tested them on the client machine
running Windows NT, you set several properties (such as code page and
URL) that need to change when the application is installed on the OS/390
host machine.

Chapter 4. Create the order servlet 81


4.7.1 About the modifications
A mirror transaction determines the environment in which the CICS user
program runs. A mirror program is a program that receives control when a
mirror transaction is attached. It receives the request, invokes the user's
program, sends the reply, and handles conversion of the commarea to and
from EBCDIC, if required.

When you ran the servlet in the development environment, you specified
CPMI for V2CSTDB and MQCP for GETORDRS. MQCP is a clone of the
CICS-supplied mirror transaction CPMI; both convert character data in the
commarea from ASCII to EBCDIC and back. You needed this conversion in
the development environment, because the servlet and CICS reside on
different machines: Windows NT and OS/390, respectively.

When you install the servlet to the OS/390 host, it is in the same environment
as the CICS server, and no conversion is required. Therefore, you must use
mirror transactions that will not cause conversion. We have defined EBMR for
V2CSTDB and MQMR for GETORDRS on the ADS machine for this purpose.
You will respecify the transactions that you want attached in the
ECIInteractionSpec objects of the command beans.

In addition, when you tested the servlet in the development environment, you
needed to specify the URL of the host CICS system. When you install the
servlet on the host, the servlet runs on the same machine as the CICS
system; that is, it is "local" to CICS. The CICS Connector supports a local
keyword so that no URL is specified. You will change the URL in the
ConnectionSpec for the command beans and the navigator bean.

4.7.2 Change the code page


For the development environment, you used the default code page of 8859_1.
The code page for the OS/390 is 037. You will reset the code page in the
record classes.
1. In the VisualAge for Java Workbench, under the order package, expand
the CustomerRecord class.
2. Click the CustomerRecord( ) method. The code for AccountRecord shows
in the lower window.
3. Find the line: attrs.setCodePage("8859_1");
4. Change the line to: attrs.setCodePage("037");
5. Save and close the CustomerRecord class.

82 Creating an Interactive B2B Web Application


6. Repeat the above steps for the class OrderRecord method inside the
OrderRecord class.

4.7.3 Change the command bean properties


You need to change the transactionName and URL properties for the two
command beans: RetrieveOrderCommand and RetrieveCustomerCommand.
To change these values, you use the Command Editor.

Important: Do not open more than one instance of the Command Editor at
the same time. VisualAge for Java can be corrupted if you do. Instead, when
you need to edit multiple command beans, edit one, save it, and then open
the next bean in the same instance of the Command Editor, as described in
the steps below.
1. In the order package, right-click the RetrieveCustomerCommand bean
and then click Tools -> Enterprise Access Builder -> Edit Command.
After a few moments, the Command Editor opens.
2. Click the Connector folder in the top left pane, and then click the
CICSConnectionSpec bean in the top right pane. The properties table for
the connection spec displays in the bottom pane.
3. Change the URL property to:
local:
Important: You must specify the colon after " local".
4. Click the ECIInteractionSpec bean in the top right pane. The properties
table for the interaction spec displays in the bottom pane.
5. Change the transactionName property to EBMR.
6. Click Command ->Save.
7. To edit the next command, click Command->Open.
8. Select RetrieveOrderCommand in the order package, and click OK.
9. Follow the same editing process to change the URL property in the
CICSConnectionSpec to:
local:
10.In the ECIInteractionSpec, change the transactionName to MQMR.
11.Click Command ->Save.
12.Close the Command Editor by selecting Command->Exit Editor.

Chapter 4. Create the order servlet 83


4.7.4 Change the navigator properties
To reset the URL property in the CICSConnectionSpec bean in
CICSRetrieveNavigator:
1. In the Workbench, double-click CICSRetrieveNavigator to open it in the
Visual Composition Editor.
2. Right-click the NavCICSConnection object and click Properties.
3. Change the URL property to:
local:
Important: You must specify the colon after "local".
4. Close the Property window.
5. Click Bean->Save Bean.
6. Close the Composition Editor window.

4.7.5 Export from VisualAge for Java to WebSphere


You need to re-export the order project to WebSphere Studio to pick up the
changed versions of the classes.
1. Right-click the order package, and click Export.
2. Select Directory, and click Next.
3. In the Export to a Directory window, click Browse and find the servlet
directory under the B2BApp project (in WebSphere Studio).
<studiopath>\projects\B2BApp\servlet\
4. Click OK.
5. In the VisualAge for Java Export SmartGuide, select the .class and .java
check boxes.
6. Click Finish.

4.8 Publish the order servlet on the server


Before you can publish the order servlet on the server, you need to make a
few changes to the some of the generated files to match the server
configuration.

4.8.1 Modify the servlet configuration file


To change the custorder.servlet file in WebSphere Studio to contain the
correct directory on the host where the JSP files reside:

84 Creating an Interactive B2B Web Application


1. Open WebSphere Studio, if it is not already open.
2. In the left pane, under the general folder, double-click the
custorder.servlet file to check it out and open it in your default editor.
3. Add /demos/b2bapp/html/ to the <uri> values for each of the JSP files. The
lines should look similar to Figure 39.

<?xml version="1.0"?>
<!-- This file was generated by IBM WebSphere Studio using
C:\WebSphere\Studio35\BIN\GenerationStyleSheets\V3\JSP1.0\ServletMod
el\ServletConfig.xsl-->
<servlet>
<markup-language>
<ml-name>HTML</ml-name>
<ml-mime>text/html</ml-mime>
<page-list>
<default-page>
<uri>/demos/b2bapp/html/custorderHTMLResults.jsp</uri>
</default-page>
<error-page>
<uri>/demos/b2bapp/html/custorderHTMLError.jsp</uri>
</error-page>
</page-list>
</markup-language>
<code>general.custorder</code>
</servlet>

Figure 39. The custorder.servlet, with changes for host publishing

4. Save the custorder.servlet file, and close the editor.


5. In the WebSphere Studio left pane, right-click the custorder.servlet file,
and click Check In.

4.8.2 Modify the user interface files


In this step you edit each of the generated user interface files to specify the
host path to the style sheet file, Master.css. You need to modify each of these
files and make the change described below.
custorderHTMLError.jsp
custorderHTMLResults.jsp
custorderHTMLInput.html

Chapter 4. Create the order servlet 85


1. In the left pane of WebSphere Studio, double-click one of the three files.
The file opens in your default editor or in Page Designer (depending on
your WebSphere settings). In Page Designer, you need to click the HTML
Source tab at the bottom of the edit pane.
2. Find the line that specifies the Master.css file, and change the link to the
/demos/b2bapp/html directory. The link should look like this:
<LINK href="/demos/b2bapp/html/theme/Master.css" rel="stylesheet"
type="text/css">
3. Save and close the file only; leave the editor open.
4. Repeat the process for the other two files; then, close the editor.
5. In the WebSphere Studio left pane, select and right-click the three files
that you just edited, and click Check In.

4.8.3 Prepare to publish on the host


In this section you set up WebSphere Studio to be able to publish the servlet
and user interface files to your host machine that is running WebSphere
Application Server, for example, your ADS machine.
1. Click Project -> Publishing Stage -> Production.
2. Click View -> Publishing.
3. If your host machine is not defined, right-click Production, and then click
Insert -> Server.
4. Type the URL of your host machine in the Server name field, and click OK.
5. In the right pane of WebSphere Studio, right-click the server name that
you just added, and click Properties.
6. For File system publish, select FTP Publish.
7. Type the FTP login ID and password for your host machine in the
appropriate fields.
If you do not know a user ID and password to use, check with your host
administrator.
8. Click Targets next to the Publishing target field.
9. Change the html publishing target to /demos/b2bapp/html. Your HTML files
and JSP files will be written to this directory.
10. Change the servlet publishing target to /demos/b2bapp/servlets. Your
servlet file and bean files will be written to this directory.
11. Click OK in the Publishing Targets window.

86 Creating an Interactive B2B Web Application


12. Click OK in the Properties window.

4.8.4 Publish the order files on the server


Now you are ready to publish the servlet and user interface files to
WebSphere Application Server on your host machine.
1. Click Project -> Publishing Stage -> Production.
2. Click View -> Publishing.
3. In the right pane of WebSphere Studio, right-click the order directory, and
click Publish this Folder.
4. Click OK for Publishing Options.
5. Click OK for Files to Publish.
6. Click Yes on all windows asking if it is OK to publish file. At the end of
publication, a results report opens in a browser.
7. In the right pane of WebSphere Studio, right-click the general directory,
and click Publish this Folder.
8. Review the reports that were generated to make sure that the all these
files were published. Table 21 summarizes where the files are published. If
any files are missing on your report, in Studio, right-click the file and select
Publish this File.
Table 21. Files published on WebSphere Application Server

Studio project files WebSphere directory

All class files in the order directory /demos/b2bapp/servlets/order

All custorder.* files in the general directory /demos/b2bapp/servlets/general

custorderHTMLInput.html /demos/b2bapp/html

custorderHTML*.jsp /demos/b2bapp/html

9. Close WebSphere Studio.

4.8.5 Check the WebSphere Application Server classpath


You need to make sure that the WebSphere Application Server classpath
contains the required references.

To check the classpath at the WebSphere Application Server:


1. Logon to the host machine (for example, your ADS server).
2. On the SDF main menu, stop the WebSphere Application Server. If you
are using an ADS machine, you can type:

Chapter 4. Create the order servlet 87


/P IMWEBSRV
3. Get into Unix System Services (USS) and edit the WebSphere
configuration file. On ADS, once you are in USS, type:
oedit /demos/websphere.cnf
4. To view the classpath, find the line starting:
appserver.classpath=...

Tip: Files in this list are separated by a colon(:).


5. Look for the following in the list. Add any missing items to the end of the
list, separating the items using a colon ( :).
/usr/lpp/ctg/classes/ctgclient.jar
/usr/lpp/ctg/classes/ctgserver.jar
/demos/jars35/webtlsrn.jar
/demos/jars35/recjava.jar
/demos/jars35/eablib.jar
Important: If webtlsrn.jar was not in the classpath, it is probably not
physically on the host machine. If it is not, you can FTP it from
<studiopath>\lib\CompileTimeClasses\AppServerV3 on your client machine
to ADS. The webtlsrn.jar file contains the StudioPervasiveServlet.class, on
which your order servlet, custorder.java, is based.
6. Save and close the configuration file, websphere.cnf.
7. On the SDF main menu, re-start the WebSphere Application Server.
/S IMWEBSRV

4.8.6 Provide permissions for the published files


To change the attributes on the files that you published so that they can be
retrieved and executed, follow the steps below.

Tip: While navigating in USS, to determine your current location, type pwd.
USS displays the current path. To verify the permissions, type: ls -all. USS
displays detailed information, including permissions, for all files and
directories in the current path. Maximum permissions look like this for a file:
-rwxrwxrwx and like this for a directory: drwxrwxrwx.

In this section, you set permission bits on the files associated with the order
servlet. We set the permissions for Read and Execute. In production, you may
decide to set them differently.

88 Creating an Interactive B2B Web Application


1. Log on to the server machine.
2. Go to the TSO command line and type: OMVS.
3. To change to the directory where the servlets are installed, type:
cd /demos/b2bapp/servlets
4. To set read and execute permissions on the general directory, type:
chmod 555 general
5. To set permissions on the order directory, type:
chmod 555 order
6. To set permissions on the files in the general directory, type:
cd general
chmod 555 custorder.*
7. To set permissions on the files in the order directory, type:
cd ../order
chmod 555 *.*
8. To set permissions on your order related files in the html directory, type:
cd ../../html
chmod 555 custorder.*

4.9 Test the order servlet from a Web browser


And now, for the moment of truth. Test the order servlet running under
WebSphere Application Server on your host (ADS) machine.

To run the order servlet:


1. Start a Web browser and specify the Web address as:
http://<host IP address>/demos/b2bapp/html/custorderHTMLInput.html

The input screen for the servlet displays, similar to Figure 40.

Chapter 4. Create the order servlet 89


Figure 40. Order servlet, running in WebSphere Application Server

2. In the customer number field, type 1 and click the Submit button.
3. The order servlet retrieves customer and order information from the DB2
CUSTOMER and ORDER tables, using the COBOL V2CSTDB and
GETORDRS applications, installed in CICS. You see something similar to
Figure 41. The data may be somewhat different.

90 Creating an Interactive B2B Web Application


Figure 41. Order servlet results, running in WebSphere Application Server

Chapter 4. Create the order servlet 91


92 Creating an Interactive B2B Web Application
Chapter 5. Create the bid servlet

In this chapter, you create the bid servlet to access MQSeries on S/390 to
request shipping options from the shipping vendors. You follow the same
steps as you would if you created your own servlet to access MQSeries:
1. Create Java beans that access MQSeries to request shipping options.
2. Test the MQ connection, using a Java application.
3. Generate the bid servlet and generic user interface files.
4. Customize the bid servlet.
5. Publish the bid servlet on the test stage.
6. Test the bid servlet in the WebSphere Test Environment.
7. Publish the bid servlet on the server.
8. Test the bid servlet from a Web browser.

5.1 Create Java beans that access MQSeries


In this section you create beans to put and get messages on MQSeries
message queues. These messages request and return shipping options from
the shipping applications. The beans provide most of the functionality for the
bid servlet. The servlet manages the interaction with the user and initiates the
execution of the command beans by instantiating and executing the
BidsNavigator.

You follow all the same steps that you would to create your own beans to
access MQSeries.
1. Create the bid package.
2. Create the BidMessageType record type.
3. Create the BidRequest record class.
4. Create the AllBidsMessageType record type.
5. Create the AllBidsReply record class.
6. Create the BidRequestCommand class.
7. Create the AllBidsReplyCommand class.
8. Create the BidsNavigator class.

© Copyright IBM Corp. 2001 93


5.1.1 Create the bid package
In VisualAge for Java:
1. Right-click the B2BAppbid project, and click Add -> Package.
2. Type bid for the Package name and click Finish.

5.1.2 Create the BidMessageType record type


In this step you create a class, called the BidMessageType, which specifies
the contents of the MQ message that you send to request shipping options, or
bids, from the shippers. The layout for this message is defined in a skeleton
COBOL program, bidmsg.ccp. Having the skeleton application lets you use
the COBOL record generator to define the message easily. Otherwise, you
would have to define the message mechanically and you would be limited in
the data types that you could specify.

See also A.1.1, “Bid messages” on page 201 for a description of the BID
message syntax.
1. In the Workbench, right-click the bid package.
2. Click Tools -> Enterprise Access Builder -> Import COBOL to Record
Type.
3. In the Import COBOL to Record Type window, click Browse. Find the
bidmsg.ccp file, located in the \client\cobol directory where you installed
the demo files, and click Open.
4. Click Next.
5. Click Next again.
6. In the Class Name field, type BidMessageType.
7. Click Finish. The CustomerRecordType class is added to the order
package and the Create Record from RecordType SmartGuide opens.

5.1.3 Create the BidRequest record class


You create a BidRequest class, of type BidMessageType, to hold the MQ
message that you will put on the HUBREQQ.
1. In the Class name field of Create Record from RecordType SmartGuide,
type BidRequest.

94 Creating an Interactive B2B Web Application


2. Set the options listed in Table 22.
Table 22. BidRequest generation options

Generation option Selection

Access Method Direct

Record Style Custom Records

Additional Options Generate with Notification

3. Click Next.
4. Specify the properties listed in Table 23 for the Record Attributes Bean.
Table 23. BidRequest record attributes

Property Value

Code Page 037

Machine Type MVS

5.Click Finish.

5.1.4 Create the AllBidsMessageType record type


In this step you create a class, called the AllBidsMessageType, which
specifies the contents of the MQ message that you receive with the shipping
option bids. The layout for this message is defined in a skeleton COBOL
program, allbidsmsg.ccp. Having this application lets you use the COBOL
record generator to define the message easily. Otherwise, you would have to
define the message mechanically and you would be limited in the data types
you could specify.

See also A.1.1, “Bid messages” on page 201 for a description of the ALLBIDS
message syntax.
1. In the Workbench, right-click the bid package.
2. Click Tools -> Enterprise Access Builder -> Import COBOL to Record
Type.
3. In the Import COBOL to Record Type window, click Browse.
4. Find the allbidsmsg.ccp file, located in the \client\cobol directory where
you installed the demo files, and click Open.
5. Click Next.
6. Click Next again on the Commarea selection window.
7. In the Class Name field, type AllBidsMessageType.

Chapter 5. Create the bid servlet 95


8. Click Finish. The CustomerRecordType class is added to the bid package
and the Create Record from RecordType SmartGuide opens.

5.1.5 Create the AllBidsReply record class


You create a AllBidsReply class, of type AllBidsMessageType, to hold the MQ
message you will get from the HUBREPQ.
1. In the Class name field of Create Record from RecordType SmartGuide,
type AllBidsReply.
2. Set the options listed in Table 24.
Table 24. AllBidsReply generation options

Generation option Selection

Access Method Direct

Record Style Custom Records

Additional Options Generate with Notification

3. Click Next.
4. Specify the properties listed in Table 25 for the Record Attributes Bean.
Table 25. AllBidsReply record attributes

Property Value

Floating Point Format IBM

Endian Big Endian

Remote Integer Endian Big Endian

Code Page 037

Machine Type MVS

5. Click Finish.

The AllBidsReply class is added to the bid package.

5.1.6 Create the BidRequestCommand class


In this step, you create a command class to:
• Connect to MQSeries on the ADS server.
• Put an input message on the Hub's request queue, HUBREQQ.

96 Creating an Interactive B2B Web Application


5.1.6.1 Define the BidRequestMessage
1. In the Workbench, right-click the bid package.
2. From the menu for the package, click Tools -> Enterprise Access
Builder -> Create Command. The Create Command SmartGuide opens.
3. In the Class name field, type BidRequestCommand.
4. Click Browse on the Connection Spec class name field.
5. From the class selection box, select MQConnectionSpec in the
com.ibm.connector.mq package, and click OK.
6. Click Browse on the Interaction Spec class name field.
7. From the class selection box, select MQInteractionSpec in the
com.ibm.connector.mq package, and click OK.
8. Click Next.

5.1.6.2 Specify the input bean


1. Make sure the Implements IByteBuffer check box is selected.
2. Click the Browse button on the Input record bean class name field.
3. Select BidRequest class in the bid package, and click OK.
4. Click Finish. The Command Editor opens.

5.1.6.3 Customize the BidRequestCommand class


1. In the Command Editor, click the Connector folder, and then click
com.ibm.connector.mq.MQConnectionSpec.
2. Set the properties listed in Table 26.
Table 26. BidRequestCommand ConnectionSpec properties

Property Value

MQSeries Channel SYSTEM.DEF.SVRCONN. On ADS, this is defined in


MQM.MQA1.SCSQPROC(CSQ4INSG).

MQSeries Queue Manager Name MQA1, which is the queue manager defined on
the ADS

Host Name The host name or IP address for the machine


with the MQSeries server. For ADS, type the IP
address of your ADS server, or type ADSYSTEM

MQSeries Output Queue Manager MQA1

Port Number The assigned port number for remote access.


Use the default, 1414, for ADS

Chapter 5. Create the bid servlet 97


Property Value

MQSeries Output Queue Name HUBREQQ

MQSeries Input Queue Name HUBREPQ

The Command Editor should look similar to Figure 42.

Figure 42. BidRequestCommand ConnectionSpec properties

3. Click the com.ibm.connector.mq.MQInteractionSpec bean in the top


right pane.
4. Click Property -> Show All Properties and set the properties listed in
Table 27.
Table 27. BidRequestCommand InteractionSpec properties

Property Value

Message Type 1 (for MQMT_REQUEST)

Execute Mode 1 (for SEND)

MQSeries Put Message Options 8196 (which is the default)

Format STRING

The Command Editor should look similar to Figure 43.

98 Creating an Interactive B2B Web Application


Figure 43. BidRequestCommand InteractionSpec properties

To customize the input bean, you specify which fields you want to put on the
HUBREQQ queue.

5.1.6.4 In the Command Editor window


1. Select the Property menu and de-select the Show all properties option.
2. In the left pane, select the Input folder, and then select bid.BidRequest in
the right pane.
3. In the properties table, select the properties BIDMSGCODE,
SVLSOURCE, and WANTDATE, right-click, and then click Promote
Property.
Tip: To select all the properties, hold down the Shift key, and click the first
and last properties.

The Command Editor should look similar to Figure 44.

Chapter 5. Create the bid servlet 99


Figure 44. BidRequestCommand BidRequest input bean properties

4. Click Command -> Save to save your changes.


5. Do not close the Command Editor yet. You will use it in the next task.

The BidRequestCommand and BidRequestCommandBeanInfo are added to


the bid package.

5.1.7 Create the AllBidsReplyCommand class


In this step, you create a command class to:
• Connect to MQSeries on the ADS server.
• Get an message from the Hub's reply queue, HUBREPQ.You use an
output bean to get a message from an MQ input queue.

5.1.7.1 Define the AllBidsReplyCommand


1. In the Command Editor, click Command -> New Command.
2. In the Create Command window, specify the properties listed in Table 28.
Table 28. AllBidsResplyCommand definition

Item Selection

Project B2BApp

Package bid

Class name AllBidsReplyCommand

3. Click Browse on the Connection Spec class name field.

100 Creating an Interactive B2B Web Application


4. From the class selection box, select MQConnectionSpec, and click OK.
5. Click Browse on the Interaction Spec class name field.
6. From the class selection box, select MQInteractionSpec, and click OK.
7. Click Next.

5.1.7.2 Specify the output bean


1. Click the Add button in the Output record beans area of the Add
Input/Output Beans SmartGuide.
2. Click Browse on the Class name field, and select the AllBidsReply class
in the bid package.
3. Click OK.
4. Click OK again.
5. Click Finish.

5.1.7.3 Customize the AllBidsReplyCommand class


1. Click the Connector folder, and then click
com.ibm.connector.mq.MQConnectionSpec.
2. Set the properties listed in Table 29.

Tip: If you see additional properties, you might have the Show All Properties
or Show Expert Properties option selected on the Properties menu. Do not
change the default settings on the additional properties.
Table 29. AllBidsReplyCommand ConnectionSpec properties

Property Value

MQSeries Channel SYSTEM.DEF.SVRCONN. On ADS, this is defined in


MQM.MQA1.SCSQPROC(CSQ4INSG).

MQSeries Queue Manager Name MQA1, which is the queue manager defined on
the ADS

Host Name The host name or IP address for the machine


with the MQSeries server. For ADS, type the IP
address of your ADS server, or type ADSYSTEM

Port Number The assigned port number for remote access.


Use the default, 1414, for ADS

MQSeries Input Queue Name HUBREPQ

The Command Editor should look similar to Figure 45.

Chapter 5. Create the bid servlet 101


Figure 45. AllBidsReplyCommand ConnectionSpec properties

3. Click the com.ibm.connector.mq.MQInteractionSpec bean in the top


right pane.
4. Set the properties listed in Table 30.
Table 30. AllBidsReplyCommand InteractionSpec properties

Property Value

Message Type 8

MQSeries Get Message Options 8197, including MQGMO_WAIT, indicates


you want to wait for the reply message

Wait Interval -1, to specify an infinite wait

Execute Mode 2, for RECEIVE

The Command Editor should look similar to Figure 46.

102 Creating an Interactive B2B Web Application


Figure 46. AllBidsReplyCommand InteractionSpec properties

To create the output bean, you specify the fields that you want to receive from
HUBREPQ.

5.1.7.4 In the Command Editor window


1. Select the Property menu, and make sure the Show all properties option
is not selected.
2. Select the Output folder, and then select bid.AllBidsReply.
3. In the properties table, select all the properties, right-click, and click
Promote Property.
The Command Editor should look like Figure 47.

Chapter 5. Create the bid servlet 103


Figure 47. AllBidsReplyCommand AllBidsReplyoutput bean properties

4. Click Command -> Save to save your changes.


5. Click Command -> Exit Editor to close the Command Editor.

5.1.8 Create the BidsNavigator class


In this step you create a navigator to manage the program flow that gets and
displays the expedited shipping options, or bids. You use the navigator to
execute an instances of the BidRequestCommand and GetReplyCommand
command classes as a single logical unit of work.

5.1.8.1 Create the class


1. Right-click the bid package, and click Add -> Class.
2. In the Create a new class field, type BidsNavigator.
3. To the right of the Superclass field, click Browse. Select
CommunicationNavigator type in the com.ibm.ivj.eab.command
package, and click OK.
4. Click Finish. The BidsNavigator class is added to the bid package.

104 Creating an Interactive B2B Web Application


5.1.8.2 Define the properties
To enable access to the data, you define properties for the data fields that you
need to access.
1. On the BeanInfo page, right-click in the Features pane, and click New
Property Feature.
2. In the Property name field, type wantdate.
3. In the Property type field, select java.lang.String and click OK.
4. Make sure these options are selected: Readable, Writeable, and bound.
5. Click Finish.
6. Repeat the same procedure to add all the properties listed in Table 31.
Table 31. BidsNavigator properties

Property name Property type

bidcode java.lang.String

servlet java.lang.String

allbidscode java.lang.String

hub java.lang.String

bidder1 java.lang.String

bidder2 java.lang.String

bidder3 java.lang.String

bid1date java.lang.String

bid2date java.lang.String

bid3date java.lang.String

bid1cost double

bid2cost double

bid3cost double

5.1.8.3 Add the connection and command beans


To add the beans:
1. On the Visual Composition page, click the Choose Bean icon in the
toolbox, and click Browse.
2. Select MQConnectionSpec in the com.ibm.connector.mq package, and
click OK.

Chapter 5. Create the bid servlet 105


3. In the Name field, type connectMQ.
4. Drop the bean on the free-form surface of the BidsNavigator.
5. Following the same procedure, add an instance of the
BidRequestCommand from the bid package, naming it putbidsrequest
6. Following the same procedure, add an instance of the
AllBidsReplyCommand from the bid package, naming it getbidsreply.

5.1.8.4 Make the property-to-property connections


Following the procedure you used earlier with the order beans, make the
property-to-property connections listed in Table 32.

Important: Make sure that the Property (not Event) option is selected in both
lists of Connectable Features
Table 32. Property-to-property connections for BidsNavigator

First object Property Second object Property

connectMQ this BidsNavigator connectionSpec

putbidsrequest WANTDATE BidsNavigator wantdate

putbidsrequest BIDMSGCODE BidsNavigator bidcode

putbidsrequest SVLSOURCE BidsNavigator servlet

getbidsreply ALLBIDSCODE BidsNavigator allbidscode

getbidsreply MSGSOURCE BidsNavigator hub

getbidsreply BIDDER1 BidsNavigator bidder1

getbidsreply BIDDER2 BidsNavigator bidder2

getbidsreply BIDDER3 BidsNavigator bidder3

getbidsreply BIDDATE1 BidsNavigator biddate1

getbidsreply BIDDATE2 BidsNavigator biddate2

getbidsreply BIDDATE3 BidsNavigator biddate3

getbidsreply BIDCOST1 BidsNavigator bidcost1

getbidsreply BIDCOST2 BidsNavigator bidcost2

getbidsreply BIDCOST3 BidsNavigator bidcost3

5.1.8.5 Make the event-to-method connections


Next, make the event-to-method connections listed in Table 33.

106 Creating an Interactive B2B Web Application


Important: Make sure that the Event (not Property) option is selected in the
first list of Connectable Features and Method (not Property) is selected in the
second list. Also, after you make each connection, select it and click Pass
event data.
Table 33. Event-to-method connections for BidsNavigator

First object Event Second object Method

BidsNavigator internalExecutionStarting putbidsrequest execute


(com.ibm.ivj.eab.
command.CommandEvent)

putbidsrequest executionUnsuccessful BidsNavigator returnExecutionUnsuccessful

putbidsrequest executionSuccessful getbidsreply execute


(com.ibm.ivj.eab.
command.CommandEvent)

getbidsreply executionUnsuccessful BidsNavigator returnExecutionUnsuccessful

getbidsreply executionSuccessful BidsNavigator returnExecutionSuccessful

5.1.8.6 Set the properties on the MQConnection bean


To set the connection properties for the BidsNavigator:
1. Right-click the MQConnectionspec object and select Properties.
2. Set the properties listed in Table 34.
Table 34. MQConnectionspec properties for BidsNavigator

Property Value

Host Name The server host name or IP address.


For example, ADSYSTEM

MQSeries Channel SYSTEM.DEF.SVRCONN

MQSeries Input Queue Name HUBREPQ

MQSeries Output Queue MQA1


Manager Name

MQSeries Output Queue HUBREQQ


Name

MQSeries Queue Manager MQA1


Name

Port Number 1414

Chapter 5. Create the bid servlet 107


5.1.8.7 Generate the code
Click Bean -> Save Bean.

The Navigator window should look similar to Figure 48.

Figure 48. BidsNavigator, in the Visual Composition Editor in VisualAge for Java

The bid package should look similar to Figure 49.

Figure 49. The bid package, containing all beans and the navigator

108 Creating an Interactive B2B Web Application


5.2 Test the MQ connection
It is a good idea to test the connection to MQSeries now. You need a class to
start the navigator. In this step, you add a class with a main method to the
package and insert some Java code to execute the navigator.

5.2.1 Create a TestBidsNav test application


In these steps, you add a test application to the bid package and supply some
Java code to execute the navigator.

5.2.1.1 Define the class


1. In the Workbench, right-click the bid package, and click Add -> Class.
2. In the Class name field, type: TestBidsNav
3. Leave the SuperClass as the default, java.lang.Object.
4. Click Next.

5.2.1.2 Add the connector packages as import statements


1. Click Add Package. The Import statement window opens.
2. Select each of these packages, and click Add:
com.ibm.connector.infrastructure
com.ibm.connector.infrastructure.java
3. Click Close in the Import statement window.

5.2.1.3 Define the main method


1. On the Attributes page of the SmartGuide, make sure the public modifier
is selected.
2. Make sure the following settings are selected:
Methods which must be implemented (Recommended)
Copy constructors from superclass (Recommended)
3. Select main(String[]).
4. Click Finish. The TestBidsNav class is added to the bids package.

5.2.1.4 Add the code to execute the navigator class


1. In TestBidsNav, open the main(String[]) method.
2. Replace the contents with the code in Figure 50.

Chapter 5. Create the bid servlet 109


public static void main(java.lang.String[] args) {
com.ibm.connector.infrastructure.java.JavaRuntimeContext
runtimeContext = new com.ibm.connector.infrastructure.
java.JavaRuntimeContext();
System.out.println(“Created New Runtime Context”);
com.ibm.connector.infrastructure.java.
JavaRuntimeContext.setCurrent(runtimeContext);
System.out.println(“Set runtimeContext”);
BidsNavigator navigation = new BidsNavigator();
System.out.println("Created new BidsNavigator");
String wantdate = "10/10/2000";
String bidcode = "BID ";
String servlet = "SERVLET ";
navigation.setWantdate(wantdate);
navigation.setBidcode(bidcode);
navigation.setServlet(servlet);
System.out.println("Set wantdate = " + navigation.getWantdate());
System.out.println("Set bidcode = " + navigation.getBidcode());
System.out.println("Set servlet = " + navigation.getServlet());

navigation.execute(new
com.ibm.ivj.eab.command.CommandEvent(navigation));
System.out.println("Executed navigation");
System.out.println("wantdate = " + navigation.getWantdate());
System.out.println("bidder1 = " + navigation.getBidder1());
System.out.println("bid1cost = " + navigation.getBid1cost());
System.out.println("bid1date = " + navigation.getBid1date());
System.out.println("bidder2 = " + navigation.getBidder2());
System.out.println("bid2cost = " + navigation.getBid2cost());
System.out.println("bid2date = " + navigation.getBid2date());
System.out.println("bidder3 = " + navigation.getBidder3());
System.out.println("bid3cost = " + navigation.getBid3cost());
System.out.println("bid3date = " + navigation.getBid3date());
((com.ibm.connector.infrastructure.java.JavaCoordinator)
runtimeContext.getCoordinator()).commit();
runtimeContext.close();
return;
}

Figure 50. TestBidsNav main method code, for testing bid beans

110 Creating an Interactive B2B Web Application


5.2.2 Run TestBidsNav to test the MQ connection
To test the connection to MQ on the ADS machine using the TestBidsNav
class:
1. Right-click the TestBidsNav class.
2. Click Run -> Check Class Path.
3. Click Compute Now.
4. When processing is complete, click OK.
5. Right-click the TestBidsNav class, and click Run -> Run Main. The
Console window opens with the result, similar to Figure 51.

Figure 51. Results of running TestBidsNav in VisualAge for Java

Chapter 5. Create the bid servlet 111


Now you know that the beans can connect to MQSeries and retrieve the
shipping options from the shipping vendor's applications.

Summary: The TestBidsNav application contains a hard-coded date that was


passed through the BidNavigator to MQHUB in an MQSeries message on the
Hub request queue, HUBREQQ. MQHUB retrieved the message and
forwarded similar messages to each of the shipper applications. The shipper
applications responded by placing their bids in messages on the MQHUB
response queue. MQHUB retrieved the messages from each of the shippers
and provided a consolidated message for the bid navigator on the Hub reply
queue, HUBREPQ. The bid navigator retrieved the message and pulled out
the individual fields to display on the console.

Next you generate a bid servlet, which uses the bid navigator and the other
bid beans that you just created. The servlet allows the bid beans to be run
from the Web.

5.2.3 Create a version of the bid package


To save your version of the bid project so that you can use it again later:
1. Right-click the bid package, and click Manage ->Version.
2. Select the Automatic option, and click OK.

5.3 Generate the bid servlet and generic user interface files
Now you are ready to generate the bid servlet. You follow a similar process to
the one you used for the order servlet, but you don’t have to repeat all of the
set up procedures.

5.3.1 Prepare to generate


To export the beans from VisualAge for Java for use by WebSphere Studio:
1. Select the bid package, and click File -> Export.
2. Select Directory and click Next.
3. In the Export to a Directory window, click Browse and find your servlet
directory in Studio:
<studiopath>\projects\B2BApp\servlet\
4. Select the .class and .java check boxes.
5. Click Finish.

112 Creating an Interactive B2B Web Application


In WebSphere Studio:
1. Right-click the servlet folder in the B2BApp project, and click Insert ->
Folder.
2. In the Insert Folder window, click the Use Existing tab.
3. Click Browse and find <studiopath>\projects\B2BApp\servlet\bid.
4. Click Add.
5. Click OK in the Insert Folder window.

To remove the read-only attributes from files in ...\B2BApp\servlet\bid:


1. In Windows NT Explorer, select all the files in the
<studiopath>\projects\B2BApp\servlet\bid directory.
Tip: Press Ctrl+A to select all the files.
2. Right-click one of the selected files, and click Properties.
3. Clear the Read-only check box, and click OK.

5.3.2 Generate the bid servlet, HTML, and JSP files


In WebSphere Studio:
1. Select B2BApp, and click Tools -> Wizards -> JavaBean Wizard.
2. From the menu select the navigator class. That is, select
...\BidsNavigator.class in the bid package.
The JavaBean name should be bid.BidsNavigator.
3. Click Next.
4. Make sure ServletModel is selected in the style of code list and HTML is
selected as the Markup Language; then click Next.
5. Select Create a page for when an error occurs. The Input page and
Results page should already be selected; leave them selected.
6. Click Next.
7. Select wantdate on the Input page.
8. Click Next.

Next, specify the properties that you want to include on the Results Page, the
page that displays the shipper options.
1. On the Results page, select these properties and use the arrow keys on
the right, to place them in this order:
bidder1

Chapter 5. Create the bid servlet 113


bid1date
bid1cost
bidder2
bid2date
bid2cost
bidder3
bid3date
bid3cost
2. Click Next.
3. On the Standard Error page, click Next.

To complete the servlet specifications:


1. On the Methods page select
execute(com.ibm.ivj.eab.command.CommandEvent), and click Next.
2. On the Session page, click Yes, store it in the user’s session.
3. Type allbids for the bean name, and click Next.
4. On the Finish page, click Rename.
5. In the Package Name field, type general
6. In the Prefix field, type shipbids
7. Click OK.
8. Click Finish.

WebSphere generates the files listed in Table 35. A message displays telling
you to edit and modify one of the generated files for input parameters, which
you do next.
Table 35. Files generated by WebSphere Studio for order servlet
Generated file Folder Purpose
shipbids.java servlet\general Servlet source
shipbids.class servlet\general Compiled servlet
shipbids.servlet servlet\general Servlet configuration file
shipbidsHTMLInput.html B2BApp Initial user interface
shipbidsHTMLResults.jsp B2BApp Used by servlet to display results
when processing runs correctly

114 Creating an Interactive B2B Web Application


Generated file Folder Purpose
shipbidsHTMLError.jsp B2BApp Used by servlet to display results
when processing does not run
correctly

5.4 Customize the bid servlet


In WebSphere Studio:
1. 1.Open B2Bapp-> servlet -> general.
2. Select shipbids.java and shipbids.class, then right-click and click Check
Out.
3. Double-click shipbids.java to open the file in your default editor.
4. Find the lines:
// allbids.execute(com.ibm.ivj.eab.command.CommandEvent);
5. Change the line to:
allbids.execute(new com.ibm.ivj.eab.command.CommandEvent(bidnav));
Important: Be sure to remove the // from the beginning of the line.
6. Immediately before the line that you just edited, insert this code:
String bidcode = "BID ";
String servlet = "SERVLET ";
allbids.setBidcode(bidcode);
allbids.setServlet(servlet);
7. Save the shipbids.java file and close your editor.
8. To compile the modified file, right-click shipbids.java, and click Compile.
A warning message displays asking whether to replace the class file.
9. Click Yes.
10.Select shipbids.java and shipbids.class, then right-click and click Check
In.

5.5 Publish the bid servlet on the test stage


To publish the bid servlet and its associated html, and JSP files on the
localhost test stage:
1. Click Project -> Publishing Stage -> Test.
2. Click View -> Publishing.
3. In the right pane, right-click the bid folder, and click Publish this Folder.

Chapter 5. Create the bid servlet 115


4. Click OK for Publishing Options.
5. Click OK for Files to Publish.
6. Click Yes on all windows asking if it is OK to publish the file.
7. Right-click the following files and click publish:
\general\shipbids.class
\general\shipbids.servlet
8. Click OK or Yes on all the windows to publish these two files.
9. Close the browser that contains the publishing report and exit from
WebSphere Studio.

You can see the files that were published by opening:


<vajpath>\ide\project_resources\IBM WebSphere Test Environment\
hosts\default_host\default_app\

Look in the servlets\bid for your Java beans and in servlets\general for the
servlet. Look in the Web directory for the .html and .jsp files.

5.6 Test the bid servlet in the WebSphere Test Environment


Just as you did for the order servlet, you set up the Servlet Engine classpath,
start the Servlet Engine, and then open your input html page in a Web
browser.

5.6.1 Start the WebSphere Test Environment


Use these steps to start the WebSphere Test Environment:
1. In the VisualAge for Java Workbench window, select the IBM WebSphere
Test Environment project, and then click Selected -> Go To -> Type.
2. Type SERunner.
3. Right-click SERunner and click Run -> Check Class Path.
4. To the right of the Project path field, click Edit.
5. Click the Select all button to choose all the projects in your workspace.
6. Scan the list of projects and make sure that the B2BApp project is not
selected. You want to make sure you run the published servlet code, not
the beans inside the development environment.
7. Click OK to close the Class Path window. The class path is updated to
include everything that you selected.

116 Creating an Interactive B2B Web Application


8. To the right of the Extra directories path field, click Edit.
9. Click Add Directory and select the servlet folder that you specified in the
publishing step above. Then add \bid to the end of that path:
<vajpath>\ide\project_resources\IBM WebSphere Test Environment\
hosts\default_host\default_app\servlets\bid
10.Click Add Directory and select the servlet folder that you specified in the
publishing step above. Then add \general to the end of that path:
<vajpath>\ide\project_resources\IBM WebSphere Test Environment\hosts\
default_host\default_app\servlets\general\
11.Click OK on all windows until you get out of the Class Path window.

5.6.2 Run the Servlet Engine


1. Right-click SERunner, and click Run -> Run main.
Alternatively, click Workspace->Tools-> Launch WebSphere Test
Environment.
2. Wait for the small WebSphere Test Environment window and the Java
Console windows to open.
3. Wait until the console messages stop.

5.6.3 Run the servlet


1. In the Location or Address field of your Web browser, type:
http://localhost:8080/shipbidsHTMLInput.html
The input page of the servlet opens, requesting a desired ship date from
the user.
2. Enter 7/30/2001 (or some other valid date, in the indicated format) in the
date field, as shown in Figure 52, and click Submit.

Chapter 5. Create the bid servlet 117


Figure 52. The bid servlet input page, running in WebSphere Test Environment

3. The servlet runs and displays the results page with the shipping options,
similar to Figure 53.

Figure 53. The bid servlet results page, running in WebSphere Test Environment

4. Close the Web browser.

118 Creating an Interactive B2B Web Application


5. To close the Test Environment, click the Stop and Exit button on the small
WebSphere Test Environment window.
6. Optional: Exit from VisualAge for Java. You do not need it anymore for the
bid servlet.

Now you know the bid servlet executes properly and you are ready to publish
it to the host.

5.7 Publish the bid servlet on the server


Before you can publish the bid servlet on the server, you need to change
some of the generated files to match the server configuration.

5.7.1 Modify the servlet configuration file


First, change the shipbids.servlet file in WebSphere Studio to contain the
correct directory on the host where the JSP files reside.
1. Open WebSphere Studio, if it is not already open.
2. In the left pane, under the general folder, double-click the
shipbids.servlet file to check it out and open it in your default editor.
3. Add /demos/b2bapp/html/ to the <uri> values for each of the JSP files. The
lines should look similar to Figure 54.

Chapter 5. Create the bid servlet 119


<?xml version="1.0"?>
<!-- This file was generated by IBM WebSphere Studio using
C:\WebSphere\Studio35\BIN\GenerationStyleSheets\V3\JSP1.0\ServletModel\Servlet
Config.xsl-->
<servlet>
<markup-language>
<ml-name>HTML</ml-name>
<ml-mime>text/html</ml-mime>
<page-list>
<default-page>
<uri>/demos/b2bapp/html/shipbidsHTMLResults.jsp</uri>
</default-page>
<error-page>
<uri>/demos/b2bapp/html/shipbidsHTMLError.jsp</uri>
</error-page>
</page-list>
</markup-language>
<code>general.shipbids</code>
</servlet>

Figure 54. The shipbids.servlet, with changes for host publishing

4. Save the shipbids.servlet file, and close the editor.


5. In the WebSphere Studio left pane, right-click the shipbids.servlet file,
and click Check In.

5.7.2 Modify the user interface files


In this step you edit each of the generated user interface files to specify the
host path to the style sheet file, Master.css. You need to modify each of these
files and make the change described below.
shipbidsHTMLError.jsp
shipbidsHTMLResults.jsp
shipbidsHTMLInput.html
1. In the left pane of WebSphere Studio, double-click one of the three files.
The file opens in your default editor or in Page Designer (depending on
your WebSphere settings). In Page Designer, you need to click the HTML
Source tab at the bottom of the edit pane.

120 Creating an Interactive B2B Web Application


2. Find the line that specifies the Master.css file, and change the link to the
/demos/b2bapp/html directory. The link should look like this:
<LINK href="/demos/b2bapp/html/theme/Master.css" rel="stylesheet"
type="text/css">
3. Save and close the file only; leave the editor open.
4. Repeat the process for the other two files; then, close the editor.
5. In the WebSphere Studio left pane, select and right-click the three files
that you just edited, and click Check In.

5.7.3 Publish the bid files on the server


Use these steps to publish the bid files on the server:
1. Click Project -> Publishing Stage -> Production.
2. Click View -> Publishing.
3. In the right pane of WebSphere Studio, right-click the bid directory, and
click Publish this Folder.
4. Click OK for Publishing Options.
5. Click OK for Files to Publish.
6. Click Yes on all windows asking if it is OK to publish file. At the end of
publication, a results report opens in a browser.
7. In the right pane of WebSphere Studio, select general\shipbids.class
and general\shipbids.servlet, right-click and click Publish selected
files.
8. Review the reports that were generated to make sure that the all these
files were published. Table 36 summarizes the files published. If any are
missing from your report, in Studio, right-click the file and select Publish
this File.
Table 36. Bid files published on WebSphere Application Server

Studio project files WebSphere directory

All class files in the bid directory /demos/b2bapp/servlets/bid

All custorder.* files in the general directory /demos/b2bapp/servlets/general

shipbidsHTMLInput.html /demos/b2bapp/html

shipbidsHTML*.jsp /demos/b2bapp/html

9. Close WebSphere Studio.

Chapter 5. Create the bid servlet 121


5.7.4 Check the WebSphere Application Server classpath
Just as you did for the order servlet, you need to make sure that the
WebSphere Application Server classpath contains the references to run your
servlet. The additional jar you need to add to run the MQ servlet is the
mqccf.jar file.

To check the classpath at the WebSphere Application Server:


1. Logon to the host machine (for example, your ADS server).
2. On the SDF main menu, stop the WebSphere Application Server. If you
are using an ADS machine, you can type:
/P IMWEBSRV
3. On the OMVS system, edit the WebSphere configuration file. On ADS:
oedit /demos/websphere.cnf
4. To view the classpath, find the line starting:
appserver.classpath=...

Tip: Files in this list are separated by a colon(:).


5. Look for the following in the list. Add any missing items to the end of the
list, separating the items using a colon ( :).
/demos/jars35/mqccf.jar:
Important: If mqccf.jar was not in the classpath, it is probably not
physically on the host machine. If it is not, you can FTP it from x:\IBM
Connectors\classes on your client machine to ADS.
6. Save and close the configuration file, websphere.cnf.
7. On the SDF main menu, restart the WebSphere Application Server.
/S IMWEBSRV

5.7.5 Provide permissions for the published files


To change the attributes on the files so that they can be retrieved and
executed:
1. Log on to the server machine.
2. Go to the TSO command line and type: OMVS.
3. To change to the directory where the servlets are installed, type:
cd /demos/b2bapp/servlets

122 Creating an Interactive B2B Web Application


4. To set read and execute permissions on the general directory, type:
chmod 555 general
5. To set permissions on the bid directory, type:
chmod 555 bid
6. To set permissions on the bid files in the general directory, type:
cd general
chmod 555 shipbids.*
7. To set permissions on the files in the bid directory, type:
cd ../bid
chmod 555 *.*
8. To set permissions on your bid related files in the html directory, type:
cd ../../html
chmod 555 shipbids.*

5.8 Test the bid servlet from a Web browser


Now you are ready to test the bid servlet from the real WebSphere
Application Server environment (on ADS).
1. Start a Web browser and specify the Web address as:
http://<host IP address>/demos/b2bapp/html/shipbidsHTMLInput.html
The input screen for the servlet displays, similar to Figure 55.

Figure 55. Bid servlet input page, in WebSphere Application Server

Chapter 5. Create the bid servlet 123


2. In the desired date field, type 7/30/2001 (or some other valid date, in the
indicated format).
3. Click the Submit button. The bid servlet retrieves shipping options from
the shipping vendors by sending an MQSeries message that is routed by
the MQHUB. You see something similar to Figure 56; the data might be
different, depending on the date that you entered.

Figure 56. Bid servlet results, in WebSphere Application Server

124 Creating an Interactive B2B Web Application


Chapter 6. Create the accept servlet

In this chapter, you create the accept servlet, which, in conjunction with
several server applications:
• Lets the customer choose a shipping option
• Updates the customer’s order information with the chosen shipping option
• Notifies the shipping vendor whose option was chosen
• Notifies the other shipping vendors that their option was not chosen
• Confirms the chosen shipping option for the customer

The accept servlet uses MQSeries to exchange messages with the Hub
application on the server. The Hub produces a specially formatted MQSeries
message for the MQ/CICS Bridge queue, which starts a CICS application to
update the DB2 ORDERS table. To learn more about the server applications
and the flow of the application, see Chapter 3, “About the server
configuration” on page 23.

To create the accept servlet, you:


1. Create Java beans to exchange MQSeries messages between the accept
servlet and the Hub application.
2. Test the MQSeries connection.
3. Generate the accept servlet and generic user interface files.
4. Customize the accept servlet.
5. Publish the accept servlet on the test stage.
6. Test the accept servlet in the WebSphere Test Environment.
7. Publish the accept servlet on the server.
8. Test the accept servlet from a Web browser.

6.1 Create Java beans to exchange MQSeries messages


First, you create beans to put an ACCEPT message on the Hub’s request
queue, HUBREQQ, and to get a confirmation message from the reply queue,
HUBREPQ. The ACCEPT message tells which shipper's bid was chosen by
the customer. See A.1, “Message syntax” on page 201.

© Copyright IBM Corp. 2001 125


When the Hub receives the request message, it sends a similar message of
type ACCEPT to the winning shipper and a message of type REJECT to the
other two shippers.

The Hub also puts a message on the MQ/CICS Bridge to run the ORUPDATE
program in CICS, which updates the ORDERS table with the new shipping
option information.

After the Hub receives an ACCEPTOK message from the winning shipper and
a confirmation message from the Bridge that their processing has completed
successfully, the Hub puts a reply message of type BOTHCONF on the Hub
reply queue, HUBREPQ, for the servlet. The accept servlet sends a Web
page, containing a confirmation code of BOTHCONF, to the customer’s
browser, as shown in Figure 57.

If, for any reason, the Hub does not receive confirmation from both the
shipper and the Bridge, it returns a message of type ERROR to the servlet.
The servlet, in turn, displays, ERROR as the confirmation code.

Figure 57. Accept servlet results, with confirmation code

The beans that you are about to create, send and receive the MQSeries
messages for the accept servlet. The servlet manages the interaction with the
user and initiates the execution of the command beans by instantiating and
executing the AcceptNavigator bean.

126 Creating an Interactive B2B Web Application


To create the beans, you:
1. Create the accept package.
2. Create the AcceptMessageType record type.
3. Create the AcceptRequestMessage record class.
4. Create the BothConfMessage record type.
5. Create the BothConfReply record class.
6. Create the AcceptRequestCommand class.
7. Create the BothConfReplyCommand class.
8. Create the AcceptNavigator class.

6.1.1 Create the accept package


In VisualAge for Java:
1. 1.Right-click the B2BApp project, and select Add -> Package.
2. Type accept for the Package name.
3. Click Finish.

6.1.2 Create the AcceptMessageType record type


In this step you create the AcceptMessageType class to define the ACCEPT
message structure. Most of the layout for this message is derived from the
commarea of the ORUPDATE COBOL program, which runs during the
processing of the ACCEPT message to update the ORDERS table.
LINKAGE SECTION.
*
* CICS COMMUNICATION AREA
*
01 DFHCOMMAREA.
02 CCUSTNO PIC S99999.
02 CITEMNO PIC S99999.
02 CSHIPDATE PIC X(10).
02 CSHIPPER PIC A(8).
02 CSHIPCOST PIC S999999V99.
02 CSQLCODE PIC S99999.

DEMOS.MQB2B.JCL(UPDATJOB) contains the ORUPDATE source.


ORUPDATE is a COBOL program, installed in the CICS Demonstration
Region. It contains embedded SQL to update the DB2 ORDERS table.
ORUPDATE executes when the Hub puts a message, containing data

Chapter 6. Create the accept servlet 127


included in the servlet's ACCEPT message (which you build in the next few
steps), on the MQ/CICS Bridge.

To create the AcceptMessageType, we wanted a message code field and a


message source field as the first two fields in the message. So we created a
skeleton COBOL program, acceptmsg.ccp, that contains these two fields and
the fields we need from ORUPDATE. The acceptmsg.ccp file is one of the
files included in the B2BApp demo files that you installed at the beginning of
this tutorial. The commarea in acceptmsg.ccp looks like this:
LINKAGE SECTION.
01 DFHCOMMAREA.
02 MSGCODE PIC X(8).
02 SOURCE PIC X(8).
02 CCUSTNO PIC S99999.
02 CITEMNO PIC S99999.
02 CSHIPDATE PIC X(10).
02 CSHIPPER PIC A(8).
02 CSHIPCOST PIC S999999V99.

To create the AcceptMessageType class:


1. In the Workbench, right-click the accept package.
2. Click Tools -> Enterprise Access Builder -> Import COBOL to Record
Type.
3. In the Import COBOL to Record Type window, click Browse. Find the
acceptmsg.ccp file, in the \client\cobol directory where you installed the
demo files, and click Open.
4. Click Next.
5. Click Next to accept DFHCOMMAREA as the commarea to import.
6. In the Class Name field, type AcceptMessageType.
7. Make sure that the follow are selected:
Continue working with newly created record type is selected
Create record from record type
8. Click Finish. The CustomerRecordType class is added to the order
package, and the Create Record from RecordType SmartGuide opens.

6.1.3 Create the AcceptRequestMessage record class


Now you create an AcceptRequestMessage class, of type
AcceptMessageType, to hold the MQ message you will put on the
HUBREQQ.

128 Creating an Interactive B2B Web Application


1. In the Class name field of Create Record from RecordType SmartGuide,
type AcceptRequestMessage and click Next.
2. Set the options listed in Table 37.
Table 37. AcceptRequestMessage generation options

Generation option Selection

Access Method Direct


Record Style Custom Records
Additional Options Generate with Notification

3. Click Next.
4. Specify the properties listed in Table 38.
Table 38. AcceptRequestmessage record attributes

Property Value

Floating Point Format IBM


Endian Big Endian
Remote Integer Endian Big Endian
Code Page 037
Machine Type MVS

5. Click Finish.

6.1.4 Create the BothConfMessage record type


In this step you create the BothConfMessageType class, which specifies the
MQ message contents that you receive from the Hub after the shipper and the
ORUPDATE programs have processed the ACCEPT message. The layout for
this message is defined in a skeleton COBOL program called
bothconfmsg.ccp.
1. In the Workbench, right-click the accept package.
2. Click Tools -> Enterprise Access Builder -> Import COBOL to Record
Type.
3. In the Import COBOL to Record Type window, click Browse. Find the
bothconfmsg.ccp file, located in the \client\cobol directory where you
installed the demo files, and click Open.
4. Click Next.
5. Click Next to accept DFHCOMMAREA as the commarea to import.

Chapter 6. Create the accept servlet 129


6. In the Class Name field, type BothConfMessageType.
7. Click Finish. The CustomerRecordType class is added to the order
package and the Create Record from RecordType SmartGuide opens.

6.1.5 Create the BothConfReply record class


You create a BothConfReply class, of type BothConfMessageType, to hold
the MQ message that you will get from the HUBREPQ.
1. In the Class name field of Create Record from RecordType SmartGuide,
type BothConfReply and click Next.
2. Set the options listed in Table 39.
Table 39. BothConfReply generation options

Generation option Selection

Access Method Direct


Record Style Custom Records
Additional Options Generate with Notification

3. Click Next.
4. Specify the properties listed in Table 40.
Table 40. AcceptRequestmessage record attributes

Property Value

Code Page 037


Machine Type MVS

5. Click Finish.

6.1.6 Create the AcceptRequestCommand class


In this step, you create a command class to:
• Connect to MQSeries on the ADS server.
• Put an input message on the Hub's request queue, HUBREQQ.

6.1.6.1 Define the AcceptRequestCommand class


1. In the Workbench, right-click the accept package.
2. From the menu for the package, click Tools -> Enterprise Access
Builder -> Create Command. After a few moments, the Create Command
SmartGuide opens.

130 Creating an Interactive B2B Web Application


3. In the Class name field, type AcceptRequestCommand.
4. Click Browse on the Connection Spec class name field.
5. From the class selection box, select MQConnectionSpec in the
com.ibm.connector.mq package, and click OK.
6. Click Browse on the Interaction Spec class name field.
7. From the class selection box, select MQInteractionSpec in the
com.ibm.connector.mq package, and click OK.
8. Click Next.

6.1.6.2 Specify the input bean


1. Make sure the Implements IByteBuffer check box is selected.
2. Click the Browse button on the Input record bean Class name field.
3. Select AcceptRequestMessage class in the accept package, and click
OK.
4. Click Finish. The Command Editor opens.

6.1.6.3 Customize the AcceptRequestCommand class


1. In the Command Editor, click the Connector folder, and then click
com.ibm.connector.mq.MQConnectionSpec.
2. Set the properties listed in Table 41.
Table 41. AcceptRequestCommand ConnectionSpec properties

Property Value

MQSeries Channel SYSTEM.DEF.SVRCONN, defined in


MQM.MQA1.SVRCONN on the ADS server

MQSeries Queue Manager Name MQA1, which is the queue manager defined on
the ADS

Host Name Your ADS host name or IP address, which is the


location of your MQSeries server. For example,
ADSYSTEM

MQSeries Output Queue manager MQA1

Port Number 1414, which is the assigned port umber for


remote access on the ADS

MQSeries Output Queue Name HUBREQQ

MQSeries Input Queue Name HUBREPQ

Chapter 6. Create the accept servlet 131


3. Click the com.ibm.connector.mq.MQInteractionSpec bean in the top
right pane.
4. Set the properties listed in Table 42.
Table 42. AcceptRequestCommand InteractionSpec properties

Property Value

Message Type 1 (for MQMT_REQUEST)

Execute Mode 1 (for SEND)

MQSeries Put Message Options 8196 (which is the default)

To customize the input bean, you specify which fields you want to put on the
HUBREQQ.
1. In the Command Editor window, select the Input folder, and then select
accept.AcceptRequestMessage.
2. In the properties table, select all the following properties.
Tip: To select all the properties, hold down the Shift key, and click the first
and last properties.
MSGSOURCE
CCUSTNO
CSHIPCOST
CSHIPDATE
CSHIPPER
CITEMNO
MSGCODE
3. Right-click and select Promote Property.
4. Click Command -> Save to save your changes.
5. Click Command -> Exit Editor to close the Command Editor.
AcceptRequestCommand and AcceptRequestCommandBeanInfo are
added to the accept package.

6.1.7 Create the BothConfReplyCommand class


In this step, you create a command class to:
• Connect to MQSeries on the ADS server.
• Use an output bean to get a message from the Hub's reply queue,
HUBREPQ.

132 Creating an Interactive B2B Web Application


6.1.7.1 Define the BothConfReplyCommand class
1. In the Workbench, right-click the accept package.
2. From the menu for the package, click Tools -> Enterprise Access
Builder -> Create Command.
3. In the Class name field, type BothConfReplyCommand.
4. Click Browse on the Connection Spec class name field.
5. From the class selection box, select MQConnectionSpec, and click OK.
6. Click Browse on the Interaction Spec class name field.
7. From the class selection box, select MQInteractionSpec, and click OK.
8. Click Next. The Add Input/output Beans SmartGuide opens.

6.1.7.2 Specify the output bean


1. Click the Add button in the Output record beans area.
2. Click Browse on the Class name field.
3. Select BothConfReply class in the accept package, and click OK.
4. Click OK again.
5. Click Finish. The Command Editor window opens.

6.1.7.3 Customize the BothConfReplyCommand class


1. Click the Connector folder, and then click:
com.ibm.connector.mq.MQConnectionSpec
2. Set the properties listed in Table 43.
Table 43. BothConfReplyCommand ConnectionSpec properties

Property Value

MQSeries Channel SYSTEM.DEF.SVRCONN

MQSeries Queue Manager Name MQA1

Host Name Your server host name, which is the


location of your MQSeries server. For
ADS, the host name is ADSYSTEM.
Alternatively, specify the server’s IP
address

Port Number 1414

MQSeries Input Queue Name HUBREPQ

MQSeries Output Queue Manager Name MQA1

Chapter 6. Create the accept servlet 133


3. Click the com.ibm.connector.mq.MQInteractionSpec bean in the top
right pane and set the properties listed in Table 44.
Table 44. BothConfReplyCommand InteractionSpec properties

Property Value

Message Type 8

MQSeries Get Message Options 8197, which includes MQGMO_WAIT


indicates you want to wait for the reply
message

Wait Interval -1, to specify an infinite wait

Execute Mode 2, for RECEIVE

Format STRING

The Command Editor should look similar to Figure 58.

Figure 58. BothConfReplyCommand InteractionSpec properties

134 Creating an Interactive B2B Web Application


To customize the output bean, you specify the fields you want to receive from
HUBREPQ.
1. In the Command Editor window, select the Output folder, and then select
accept.BothConfReply.
2. In the properties table, select these properties:
BOTHCONF
SOURCE
3. Right-click, and click Promote Property.
4. Click Command -> Save to save your changes.
5. Click Command -> Exit Editor to close the Command Editor.

6.1.8 Create the AcceptNavigator class


In this step you create a navigator to manage the program flow to accept one
of the shipping options. You use an AcceptRequestCommand to construct
and send a message to the HUB. The message indicates which bid was
accepted and provides the data to update the ORDERS table (that is, the
customer number, item number, shipper, new ship date, and new cost for
shipping). You use a BothConfReplyCommand to get notification from the
Hub that the shipper confirmed acceptance and that the ORDERS table
update occurred.

6.1.8.1 Create the navigator class


1. Right-click the accept package, and click Add -> Class.
2. In the Create a new class field, type AcceptNavigator.
3. To the right of the Superclass field, click Browse.
4. Select CommunicationNavigator type in the com.ibm.ivj.eab.command
package, and click OK.
5. Click Finish.

6.1.8.2 Define the properties


To enable access to the data, define properties for the data fields that you
need to access.
1. Double-click the AcceptNavigator class to open it in the Visual
Composition editor.
2. Click on the BeanInfo tab.
3. Right-click in the Features pane, and click New Property Feature.

Chapter 6. Create the accept servlet 135


4. Using the New Property Feature SmartGuide, add each of the properties
listed in Table 45, setting the property type, and selecting these options for
each: Readable, Writable, and bound.
Tip: You need to repeat the previous step to re-open the SmartGuide for
each property.
Table 45. AcceptNavigator properties

Property name Property type

msgCode java.lang.String

msgSource java.lang.String

customerNumber int

orderItemNumber int

orderShipDate java.lang.String

orderShipper java.lang.String

orderShipCost double

bothConf java.lang.String

6.1.8.3 Add the connection and command beans


1. On the Visual Composition page, click the Choose Bean icon in the
toolbox, and click Browse.
2. Select MQConnectionSpec in the com.ibm.connector.mq package, and
click OK.
3. In the Name field, type acceptMQconnection.
4. Drop the bean on the free-form surface of the AcceptNavigator.
5. Following the same procedure, add an instance of the
AcceptRequestCommand from the accept package, naming it
putacceptrequest.
6. Following the same procedure, add an instance of the
BothConfReplyCommand from the accept package, naming it
getbothconfreply.
The Visual Composition editor should look similar to Figure 59.

136 Creating an Interactive B2B Web Application


Figure 59. AcceptNavigator in Visual Composition editor

6.1.8.4 Make the property-to-property connections


Make all of the connections shown in Table 46, making sure that the Property
(not Event) option is selected in both lists of Connectable Features.
Table 46. AcceptNavigator property-to-property connections

First object Property Second object Property

acceptMQconnection this AcceptNavigator connectionSpec

putacceptrequest MSGCODE AcceptNavigator msgCode

putacceptrequest MSGSOURCE AcceptNavigator msgSource

putacceptrequest CCUSTNO AcceptNavigator customerNumber

putacceptrequest CITEMNO AcceptNavigator orderItemNumber

putacceptrequest CSHIPCOST AcceptNavigator orderShipCost

putacceptrequest CSHIPDATE AcceptNavigator orderShipDate

putacceptrequest CSHIPPER AcceptNavigator orderShipper

getbothconfreply BOTHCONF AcceptNavigator bothConf

Chapter 6. Create the accept servlet 137


6.1.8.5 Make the event-to-method connections
Make all of the connections listed in Table 47, making sure that the Event
(not Property) option is selected in the first list of Connectable Features and
Method (not Property) is selected in the second list.
Table 47. AcceptNavigator event-to-method connections

First object Event Second object Method

AcceptNavigator internalExecutionStarting putacceptrequest execute


(com.ibm.ivj.eab.command.
CommandEvent)

putacceptrequest executionUnsuccessful AcceptNavigator returnExecutionUnsuccessful

putacceptrequest executionSuccessful getbothconfreply execute


(com.ibm.ivj.eab.command.
CommandEvent)

getbothconfreply executionUnsuccessful AcceptNavigator returnExecutionUnsuccessful

getbothconfreply executionSuccessful AcceptNavigator returnExecutionSuccessful

6.1.8.6 Set these properties on the acceptMQconnection bean


To set the connection properties for the navigator:
1. Right-click the acceptMQConnection object and select properties.
2. Set the properties shown in Table 48.
Table 48. acceptMQConnection properties for the AcceptNavigator

Property Value

Host Name The server host name or IP address.


For example, ADSYSTEM

MQSeries Channel SYSTEM.DEF.SVRCONN

MQSeries Input Queue Name HUBREPQ

MQSeries Output Queue Manager Name MQA1

MQSeries Output Queue Name HUBREQQ

MQSeries Queue Manager Name MQA1

Port Number 1414

6.1.8.7 Generate the code


Click Bean -> Save Bean.

The Navigator window should look similar to Figure 60.

138 Creating an Interactive B2B Web Application


Figure 60. Finished AcceptNavigator, with connections

The accept package should look similar to Figure 61.

Figure 61. The accept package, containing all the beans and the navigator

Chapter 6. Create the accept servlet 139


6.2 Test the MQ connection
Just as you tested the order and bid navigators before creating the servlets,
you now test the accept navigator.

6.2.1 Create the TestAcceptNav class


In these steps you create the TestAcceptNav class.

6.2.1.1 Define the class


1. In the Workbench, right-click the accept package, and click Add -> Class.
2. In the Class name field, type: TestAcceptNav
3. Leave the SuperClass as the default, java.lang.Object.
4. Click Next.

6.2.1.2 Add the connector packages as import statements


1. Click Add Package. The Import statement window opens.
2. Select com.ibm.connector.infrastructure and click Add.
3. Select com.ibm.connector.infrastructure.java and click Add.
4. Click Close in the Import statement window.

6.2.1.3 Create the main method, which gets control when you test
1. On the Attributes page of the SmartGuide, make sure the public modifier
is selected.
2. Make sure the following settings are selected:
Methods which must be implemented (Recommended)
Copy constructors from superclass (Recommended)
3. Select main(String[]).
4. Click Finish. The TestAcceptNav class is added to the accept package.

6.2.1.4 Add the code to execute the navigator class


1. In TestAcceptNav, double-click main(Strng[]).
2. Replace the contents with the code shown in Figure 62.

140 Creating an Interactive B2B Web Application


public static void main(java.lang.String[] args) {
// Set up connector runtime
com.ibm.connector.infrastructure.java.JavaRuntimeContext
runtimeContext = new com.ibm.connector.infrastructure.
java.JavaRuntimeContext();
System.out.println("Created New Runtime Context for TestExecute");
com.ibm.connector.infrastructure.java.
JavaRuntimeContext.setCurrent(runtimeContext);
AcceptNavigator accnav = new AcceptNavigator();
System.out.println("Created new AcceptNavigator");
// Define input parameters
int custnum=3;
int itemnum=4156;
String shipper="SHIPPER3";
String shipdate="12/21/2000";
double shipcost=.25;
accnav.setCustomerNumber(custnum);
accnav.setOrderItemNumber(itemnum);
accnav.setOrderShipper(shipper);
accnav.setOrderShipDate(shipdate);
accnav.setOrderShipCost(shipcost);
// Define required message parameters
String acceptcode = "ACCEPT ";
String servletsource = "SERVLET ";
accnav.setMsgCode(acceptcode);
accnav.setMsgSource(servletsource);
accnav.execute(new com.ibm.ivj.eab.command.CommandEvent(accnav));
// Display values after execution
System.out.println("Executed accnav");
System.out.println("Customer Num = " + accnav.getCustomerNumber());
System.out.println("Item Number = " + accnav.getOrderItemNumber());
System.out.println("Ship Date = " + accnav.getOrderShipDate());
System.out.println("Ship Cost = " + accnav.getOrderShipCost());
System.out.println("BothConf = " + accnavaccnav.getBothConf());
// Close runtime
((com.ibm.connector.infrastructure.java.JavaCoordinator)
runtimeContext.getCoordinator()).commit();
runtimeContext.close();
return;
}

Figure 62. TestAcceptNav main method, for testing accept beans

Chapter 6. Create the accept servlet 141


6.2.2 Run TestAcceptNav to test the MQ connection
To test the MQ connection using the TestAcceptNav class:
1. Right-click the TestAcceptNav class, and click Run -> Check Class Path.
2. Click Compute Now.
3. When processing is complete, click OK.
4. Right-click the TestAcceptNav class, and click Run -> Run Main.

The Console window opens with the result, similar to Figure 63.

Figure 63. Results of running TestAcceptNav in VisualAge for Java

Now you know that the:


• Accept beans can connect to MQ
• Server applications are getting the correct input and can update the
ORDERS table using the MQ/CICS Bridge
• Shipper applications are getting notified who got the bid

If you did not see the correct result or the debugger window opened, see
Chapter 9, “Troubleshooting” on page 199.

142 Creating an Interactive B2B Web Application


6.2.3 Review what you have demonstrated
The TestAcceptNav application contains hard-coded data that was passed
through the AcceptNavigator to the Hub in an MQSeries message on the Hub
request queue, HUBREQQ.

The Hub sent an ACCEPT message to the winning shipper and a REJECT
message to the other two. The Hub also put a message on the MQ/CICS
Bridge to run the ORUPDATE program in CICS to update the ORDERS table
with the new shipping option information.

After the Hub received confirmation from the winning shipper and from the
Bridge, the Hub put a message on the Hub reply queue, HUBREPQ, for the
AcceptNavigator. TestAcceptNav accesses properties in AcceptNavigator to
display the results on the console.

Next you generate the accept servlet, which uses the AcceptNavigator and
the other accept beans that you just created (or imported). The servlet
enables the accept beans to run as a Web application.

6.2.4 Create a version the accept package


Save your accept project as a version so that you can reuse it at a later time.
1. Right-click the accept package, and click Manage -> Version.
2. Select the Automatic option, and click OK.

6.3 Generate the accept servlet and generic user interface files
In this section, you generate the servlet code to interact with the user and to
invoke the accept beans you just create.

6.3.1 Getting the accept bean files into WebSphere Studio


In VisualAge for Java:
1. Select the accept package, and click File -> Export.
2. Select Directory and click Next.
3. Click Browse and find the servlet directory under the B2BApp project that
you created earlier in Studio:
<studiopath>\projects\B2BApp\servlet\
4. Select the .class and .java check boxes.
5. Click Finish.

Chapter 6. Create the accept servlet 143


In WebSphere Studio:
1. In the B2BApp project, right-click the servlet folder, and click Insert ->
Folder.
2. In Insert Folder window, click the Use Existing tab.
3. Click Browse, and find:
<studiopath>\projects\B2BApp\servlet\accept
4. Click OK.
5. Click Add.
6. Click OK in the Insert Folder window.

Remove the read-only attributes


1. In Windows NT Explorer, select all the files in the
<studiopath>\projects\B2BApp\servlet\accept directory.
Tip: Press Ctrl+A to select all the files.
2. Right-click one of the selected files, and click Properties.
3. Clear the Read-only check box, and click OK.

6.3.2 Generate the accept servlet, HTML, and JSP files


In WebSphere Studio:
1. Select B2BApp.
2. Click Tools ->Wizards ->JavaBean Wizard.
3. From the list, select the navigator class. That is, select
...\AcceptNavigator.class.
The JavaBean name should read: accept.AcceptNavigator
4. Click Next.
5. Make sure ServletModel is selected in the style of code list and that
HTML is selected in the Markup Language list; then click Next.
6. Make sure that input page and results page are also selected.
7. Select Create a page for when an error occurs.
8. Click Next.
9. On the Input Page, select these fields, and use the arrow keys to the right
of the window to place them in this order:
customerNumber
orderItemNumber

144 Creating an Interactive B2B Web Application


orderShipper
orderShipDate
orderShipCost
10.Click Next.

Next, specify the properties that you want to show up on the user’s
confirmation page:
1. On the Results Page, select these fields and place them in this order:
bothConf
customerNumber
orderItemNumber
orderShipper
orderShipDate
orderShipCost
2. Click Next.
3. On the Standard Error Page, click Next.

Complete the servlet definition


1.On the Methods page select:
execute(com.ibm.ivj.eab.command.CommandEvent)
4. Click Next.
5. On the Session page, select Yes, store it in the user’s session.
6. Type accnav for the bean name, and click Next.
7. On the Finish page, click Rename.
8. In the Package Name field, type general.
9. In the Prefix field, type acceptdate, and click OK.
10.Click Finish.

WebSphere generates the files shown in Table 49. A message displays telling
you to edit and modify one of the generated files for input parameters, which
you do next.
Table 49. Files generated by WebSphere Studio for accept servlet

Generated file Folder Purpose

acceptdate.java servlet\general Servlet source

Chapter 6. Create the accept servlet 145


Generated file Folder Purpose

acceptdate.class servlet\general Compiled servlet

acceptdate.servlet servlet\general Servlet configuration file

acceptdateHTMLInput.html B2BApp Initial user interface

acceptdateHTMLResults.js B2BApp Used by servlet to display results


p when processing runs correctly

acceptdateHTMLError.jsp B2BApp Used by servlet to display results


when processing does not run
correctly

11.Click OK to dismiss the message.

6.4 Customize the accept servlet


In WebSphere Studio:
1. Open B2BApp -> servlet -> general.
2. Select acceptdate.java and acceptdate.class, then right-click and click
Check Out.
3. Double-click acceptdate.java to open the file in your default editor.
4. Find the lines:
// The following line is commented so the user can manually edit the
code and type the parameters.
// accnav.execute(com.ibm.ivj.eab.command.CommandEvent);
5. Change the second line to:
accnav.execute
(new com.ibm.ivj.eab.command.CommandEvent(accnav));
Important: Be sure to remove the // at the beginning of the line.
6. Add this code immediately before the line that you just modified:
String acceptcode = "ACCEPT ";
String msgsource = "SERVLET ";
accnav.setMsgCode(acceptcode);
accnav.setMsgSource(msgsource);
7. Save acceptdate.java and close your editor.
8. To compile the modified file, right-click acceptdate.java, and click
Compile.
A warning message displays asking whether to replace the class file.

146 Creating an Interactive B2B Web Application


9. Click Yes.
10.Select acceptdate.java and acceptdate.class, then right-click and click
Check In.

6.5 Publish the accept servlet on the test stage


Assuming that you have already set up the publishing environment (see “Set
up Studio publishing for local testing” on page 76), you are now ready to
publish the servlet so you can test locally.

To publish the accept servlet and its associated HTML and JSP files:
1. Click Project -> Publishing Stage -> Test.
2. Click View -> Publishing.
3. In the right pane, right-click the accept folder, and click Publish this
Folder.
4. Click OK for Publishing Options.
5. Click OK for Files to Publish.
6. Click Yes on all windows asking if it is OK to publish the file.
7. Close the browser that contains the publishing report and exit from
WebSphere Studio.

6.6 Test the accept servlet in the WebSphere Test Environment


Follow the instructions for your release of VisualAge for Java.
1. In the IBM WebSphere Test Environment project, open the
com.ibm.servlet package.
2. Right-click SERunner and click Run -> Check Class Path.
3. To the right of the Project path field, click Edit.
4. Click the Select all button to choose all the projects in your workspace.
5. Scan the list of projects and make sure that the B2BApp project is not
selected. You want to make sure you run the published servlet code, not
the beans inside the development environment.
6. Click OK to close the Class Path window. The class path is updated to
include everything that you selected.
7. To the right of the Extra directories path field, click Edit.

Chapter 6. Create the accept servlet 147


8. Click Add directory and select the servlet folder that you specified in the
publishing step above. Add the accept directory to the end of that path:
<path>\ide\project_resources\IBM WebSphere Test Environment\hosts\
default_host\default_app\servlets\acceptxx\
9. Click OK on all windows until you get out of the Class Path window.

Run the Servlet Engine


1. Right-click SERunner, and click Run -> Run main.
2. Wait for the small WebSphere Test Environment window and the Java
Console windows to open.
3. Wait until the console messages stop.

Run the servlet


1. In the Location or Address field of your Web browser, type:
http://localhost:8080/acceptdateHTMLInput.html
2. The input page of the servlet opens. The browser should look similar to
Figure 64.

148 Creating an Interactive B2B Web Application


Figure 64. Accept servlet input page, in WebSphere Test Environment

3. Enter the data shown in Table 50, and click Submit.


Table 50. Data to enter into accept servlet input page

Field name Type this value:

customerNumber 3

orderItemNumber 4156

orderShipper SHIPPER3

orderShipDate 10/31/2000

orderShipCost .20

Chapter 6. Create the accept servlet 149


The accept servlet runs and displays the results page, indicating a
confirmation code of BOTHCONF, similar to Figure 65.

Figure 65. Accept servlet results, in WebSphere Test Environment

If the bothConf confirmation code is ERROR instead of BOTHCONF, see Chapter 9,


“Troubleshooting” on page 199.

You are finished with WebSphere Test Environment for now, so you can stop
it.

6.7 Publish the accept servlet on the server


Before you can publish the accept servlet to the server, you need to change
some of the generated files to match the server configuration.

6.7.1 Modify the servlet configuration file


To change the acceptdate.servlet file to specify the correct server directory
for JSP files:
1. Open WebSphere Studio, if it is not already open.
2. In the left pane, double-click acceptdate.servlet to open it in your default
editor.
3. Add /demos/b2bapp/html/ to the uri values for each of the JSP files. The
lines should look similar to Figure 66.

150 Creating an Interactive B2B Web Application


<page-list>
<default-page>
<uri>/demos/b2bapp/html/acceptdateHTMLResults.jsp</uri>
</default-page>
<error-page>
<uri>/demos/b2bapp/acceptdateHTMLError.jsp</uri>
</error-page>
</page-list>
<code>general.acceptdate</code>

Figure 66. A portion of the acceptdate servlet configuration file

4. Save the acceptdate.servlet file and close the editor.


5. In the WebSphere Studio left pane, right-click acceptdate.servlet, and
click Check In.

6.7.2 Modify the user interface files


In this step you edit each of the generated user interface files to specify the
host path to the style sheet file, Master.css. You need to modify each of these
files and make the change described below:
acceptdateHTMLError.jsp
acceptdateHTMLResults.jsp
acceptdateHTMLInput.html
1. In the left pane of WebSphere Studio, double-click one of the three files.
The file opens in your default editor or in Page Designer (depending on
your WebSphere settings).
2. In Page Designer, you need to click the HTML Source tab at the bottom of
the edit pane.
3. Find the line that specifies the Master.css file, and change the link to the
/demos/b2bapp/html directory. The link should look like this:
<LINK href="/demos/b2bapp/html/theme/Master.css" rel="stylesheet"
type="text/css">
4. Save and close the file only; leave the editor open.
5. Repeat the process for the other two files; then, close the editor.
6. In the WebSphere Studio left pane, select and right-click the three files
that you just edited, and click Check In.

Chapter 6. Create the accept servlet 151


6.7.3 Publish the accept files on the server
Use these steps to publish the accept files on the server:
1. Click Project -> Publishing Stage -> Production.
2. Click View -> Publishing.
3. In the right pane of WebSphere Studio, right-click the accept directory,
and click Publish this Folder.
4. Click OK for Publishing Options.
5. Click OK for Files to Publish.
6. Click Yes on all windows asking if it is OK to publish file. At the end of
publication, a results report opens in a browser.
7. After you have finished reviewing the report, close the browser.
8. Close WebSphere Studio.

6.7.4 Provide permissions for the published accept files


In this section, you set permission bits on the files associated with the accept
servlet. We set the permissions for Read and Execute. In a production, you
may decide to set them differently.

To change the attributes on the files so that they can be retrieved and
executed:
1. Log on to the server machine.
2. Go to the TSO command line and type: OMVS.
3. To set maximum permissions on the files in the accept directory, type:
cd demo/b2bapp/servlets/accept
chmod 555*
4. To set maximum permissions on the acceptdate files in the general
directory, type:
cd ..
chmod 555 acceptdate.*
5. To set maximum permissions on the files in the html directory, type:
cd ../html
chmod 555 acceptdate.*

152 Creating an Interactive B2B Web Application


6.8 Test the accept servlet from a Web browser
Now you are ready to test the accept servlet from the real WebSphere
Application Server environment (on ADS).

To run the accept servlet:


1. Start a Web browser and specify the following Web address:
http://< host IP address>/demos/b2bapp/html/acceptdateHTMLInput.html
2. Enter the data shown in Figure 67 and click Submit.

Figure 67. Accept servlet input page, in WebSphere Application Server

Chapter 6. Create the accept servlet 153


The results should look similar to Figure 68.

Figure 68. Accept servlet results, in WebSphere Application Server

6.9 Summary
The accept servlet communicates through MQSeries to notify the shipper
applications which one got the bid. The Hub also uses the MQ/CICS Bridge to
run a CICS application to update the ORDERS table. The confirmation code
of BOTHCONF is the signal that both of these transactions happened
successfully. To be totally convinced that the update occurred, run the order
servlet and specify customer number 3. You should see that the shipping
information has changed to match the information you entered.

In the next chapter, you see how to put the servlets together so that the data
from servlet flows to the next and so the user has a cohesive interface. That
is, you turn the servlets into an interactive Web application.

154 Creating an Interactive B2B Web Application


Chapter 7. Create the email servlet

In this chapter you create the servlet that sends email to the customer to
confirm the order. To accomplish this task, you:
1. Create Java beans that connects to IMS, using the IMS Connector for
Java, and retrieves the customer’s email address.
2. Develop a Java Server Page (JSP) to test the beans.
3. Create a servlet to execute the bean and send the email.

7.1 Create the IMS beans


In this section, you create a set of beans, including the command bean, to
connect to IMS and retrieve the customer’s email address. You use the
JAVATRAN transaction, which is written in COBOL, and a feature of
VisualAge to parse the transaction source and create input and output record
classes.

7.1.1 Create the package


From the VisualAge for Java Workbench:
1. Right-click the B2BApp project, and click Add -> Package.
2. Enter imsemail as the name for the new package, and click Finish.

7.1.2 Create a RecordType for the input message


This step parses the COBOL program that represents the input message for
the IMS transaction.
1. Right-click the imsemail package and click Tools -> Enterprise Access
Builder -> Import COBOL to RecordType. The Import COBOL to Record
Type SmartGuide opens.
2. Click Browse, find the javapgm.txt, located in the \client\ims directory
where you installed the demo files, and click Open.
The next window displays a list of the available level 01 commareas, as
shown in Figure 69.

© Copyright IBM Corp. 2001 155


Figure 69. COBOL to Record Type SmartGuide Commarea Selection Window

3. Select INPUT-MSG as the commarea representing the IMS transaction


input message and click the > button to add it to the Selected commareas.
4. Select the Use BigDecimal check box. This will generate the COBOL type
as a BigDecimal Java type. Click Next.
5. Ensure that the Project Name is B2BApp and the Package name is
imsemail.
6. Enter InMsgInfo for the new COBOL RecordType class.

156 Creating an Interactive B2B Web Application


7. Ensure that both the Continue working with newly created record type
check box and the Create record from record type radio button are
selected, and click Finish.
A new class named InMsgInfo is added to the imsemail package. After
some processing the Create Record from Record Type SmartGuide
Window will open.

In the next step you create the Transaction Input Record Bean.

7.1.3 Create a transaction input record bean


This step creates a record bean that represents the transaction input
message from the COBOL RecordType class created above. A record bean
contains properties that map to the fields in a record in a host program. In this
case, the record in the host program is the IMS transaction input message.
1. Type InMsg for the new class, which will represent the input message.
2. Choose Access Method: Direct; and, choose Record Style: Custom
Records.
3. In Additional Options, ensure that the following check box is selected:
Generate with Notification. Do not check Use Inner Classes or Shorten
Names.
4. Click Next, and select the following properties:
a. Floating Point Format is IBM.
b. Remote Integer Endian is Big Endian.
c. Endian is Big Endian.
d. Code Page is 037. Important: This is the code page of the data of the
IMS transaction. If your transaction data is other than U.S. English
(code page 037), you must enter a different code page in this field.
e. Machine Type is MVS. (This value represent the fact that the IMS
transaction input message is processed on an MVS host machine.)
f. Click Finish. The InMsg class is added to the package imsemail in the
IDE Workbench. To summarize, the InMsg Java bean represents the
IMS transaction input message.

7.1.4 Create a RecordType for the output message


This step parses the COBOL program that represents the output message for
the IMS transaction.

Chapter 7. Create the email servlet 157


1. Right-click the imsemail package, and click Tools -> Enterprise Access
Builder -> Import COBOL to RecordType.
2. Click Browse, find the javapgm.txt, located in the \client\ims directory
where you installed the demo files, and click Open.
3. Click Next.
4. Select OUTPUT-AREA as the commarea representing the IMS transaction
output message from the Available level 01 commarea list and add it to the
Selected commareas list by clicking the > button.
5. Select the Use BigDecimal check box.
6. Ensure that the Project Name is B2BApp and the Package name is
imsemail.
7. Enter OutMsgInfo, for the new class, which will represent the COBOL
RecordType.
8. Ensure that both the Continue working with newly created record type
check box and the Create record from record type radio button are
selected, and click Finish.
A new class named OutMsgInfo is added to the imsemail package.

After some processing the Create Record from Record Type SmartGuide
Window opens. The next step is to create the Transaction Output Record
Bean.

7.1.5 Create a transaction output record bean


This step creates a record bean that represents the transaction output
message from the COBOL RecordType class created above. A record bean
contains properties that map to the fields in a record in a host program. In this
case, the record in the host program is the IMS transaction output message.
1. Type OutMsg for the new class, which will represent the input message.
Click Access Method: Direct; and, Record Style: Custom Records.
2. In Additional Options, ensure that the following check box is selected:
Generate with Notification. Do not check Use Inner Classes or Shorten
Names.
3. Click Next, and select the following properties:
a. Floating Point Format is IBM.
b. Remote Integer Endian is Big Endian.
c. Endian is Big Endian.

158 Creating an Interactive B2B Web Application


d. Code Page is 037. Important: This is the code page of the data of the
IMS transaction. If your transaction data is other than U.S. English
(code page 037), you must enter a different code page in this field.
e. Machine Type is MVS.
f. Click Finish on the Create Record from Record Type SmartGuide. Two
new classes, OutMsgBeanInfo and OutMsg, appear in the package
imsemail in the IDE Workbench. The OutMsg Java bean represents the
IMS transaction output message.

After this is completed, your IDE Workbench window should look similar to
Figure 70.

Figure 70. IDE Workbench window with transaction input and output classes

7.1.6 Create a command class for the IMS transaction


This section describes how you can create an Enterprise Access Builder
(EAB) command using the VisualAge for Java Create Command SmartGuide.
The SmartGuide walks you through the steps of constructing a command,
allowing you to focus on the specific composition patterns of a command. The
imsemail command is a composite bean consisting of:
• A ConnectionSpec bean
• An InteractionSpec bean
• A bean representing the input of the transaction

Chapter 7. Create the email servlet 159


• A bean representing the output of the transaction
• The DFSMsg bean

The DFSMsg bean is used to process messages from IMS other than the
output of the transaction, such as error or status messages.

7.1.6.1 Create a class for the imsemail command


1. With the imsemail package selected, from the Selected menu, click Tools
-> Enterprise Access Builder -> Create Command. The Create
Command SmartGuide opens.
2. Ensure that the correct names appear in the Project Name and Package
entry fields.
3. Enter EABExecutecmd for the new class that represents the EAB command,
as shown in Figure 71.

160 Creating an Interactive B2B Web Application


Figure 71. VisualAge for Java Create Command SmartGuide

4. Ensure that the Edit when finished check box is selected.


5. To associate a connection specification with the IMS command, click the
Browse button, choose IMSConnectionSpec, and click OK.
6. Click Edit to edit the connection specification properties. Set the following
property values. (Make sure to use the values that represent your
environment’s configuration):
a. Host name: Enter the MVS host name or IP address of the machine
running the IMS Connect that the command (IMS transaction) will be
using.

Chapter 7. Create the email servlet 161


b. Port: Enter the port for the IMS TCP/IP OTMA Connection that the
command (IMS transaction) will be using. On our ADS system, this is
3336. Figure 72 shows the property settings.

Figure 72. IMS Connection Specification properties

c. Leave all other properties unchanged and click OK.


7. To associate an interaction specification with the EAB command, click the
Browse button, choose IMSInteractionSpec, and click OK.
8. To set up access to the IMS datastore:
a. Click Edit, select the Datastore name property name, and enter the
name of the target IMS datastore: IMS1I. (Make sure that you use the
datastore that matches your environment).
b. Leave all other values as they are and click OK. Figure 73 shows the
property settings.

162 Creating an Interactive B2B Web Application


.

Figure 73. IMS Interaction Specification Properties

9. Click Next to add the Input and Output Beans.

7.1.6.2 Specify the Transaction Input and Output Beans


1. In the Input record bean section, ensure that the Implements IByteBuffer
check box is selected.
Click Browse, select the InMsg Type Name in the imsemail package, and
click OK. Figure 74 shows the bean selection.

Chapter 7. Create the email servlet 163


Figure 74. VisualAge for Java Input Record Bean Selection

2. In the Output record bean section, ensure that Select output record
beans is selected.
3. Click the Add button. A dialog box appears to enter the output record
bean. In this dialog box, ensure that the Implements IByteBuffer check
box is selected.
4. Click Browse, select the OutMsg Type Name and the imsemail Package
Name, and click OK.
5. Repeat the above procedure for additional output record beans, if
necessary. In our case, repeat the procedure to add the output record
bean with DFSMsg as Type Name and com.ibm.connector.imstoc as the
Package Name. Figure 75 shows the two selected output beans.

164 Creating an Interactive B2B Web Application


.

Figure 75. VisualAge for Java Input/Output Record Bean selection

6. Click Finish. After a few moments, the Command Editor opens.

Tip: The command editor is also accessible through Tools -> Enterprise
Access Builder -> Edit Command.

7.1.6.3 Promote the IMS transaction input properties


Promoting the values is necessary to create the methods that are used to get
and set the corresponding values from outside the bean. Also in the
command editor you can hardcode defaults, which may be overridden using
the set methods of the promoted properties.

Chapter 7. Create the email servlet 165


1. In the Command Editor, select the Input folder under the
imsemail.imsemailcmd icon in the top left pane. The input bean displays in
the top right pane.
2. Select the input bean, imsemail.InMsg. The properties and their values
display in the bottom pane.
3. Select the IN_COMMAND property in the bottom pane. In the Value
column on the right, enter DIS (upper case).
4. Select the IN_TRAN property, and enter JAVATRAN.
5. Select the IN_LL property, and enter 206.
6. Right-click the IN_LL property, and choose Promote Property on the
pop-up context menu. The promoted property is marked with a green dot
in front of the property name. By default, properties are promoted with the
same name as the originating bean.
7. Repeat the previous step to promote the following properties: IN_ZZ,
IN_TRAN, IN_COMMAND, IN_CUST_ID.
Some of these properties are not used, because the default values do not
need to be changed, but promote them anyway, so you have the capability
to change them.
Figure 76 shows the promoted properties.

166 Creating an Interactive B2B Web Application


Figure 76. The imsemail input bean properties

7.1.6.4 Promote the IMS transaction output properties


To add features of an output transaction bean to the interface of a composite
bean, you promote them to the composite's interface.
1. In the Command Editor, select the Output folder in the top left pane, and
select the output bean, imsemail.OutMsg, in the top right pane.
2. Right-click the OUT_LL property in the bottom pane, and choose Promote
Property.

Chapter 7. Create the email servlet 167


3. Repeat the procedure to promote the following properties: OUT-ZZ,
OUT-COMPANY, OUT-LAST-NAME, OUT-FIRST-NAME, OUT-ADDRESS,
OUT-CITY, OUT-STATE, OUT-COUNTRY.
Figure 77 shows the promoted output bean properties.

Figure 77. The imsemail output bean properties

4. Select the output bean, com.ibm.connector.DFSMsg.


5. Right-click the DFSDATA1 property in the bottom pane, and choose
Promote Property on the pop-up context menu.

7.1.6.5 Promote the InteractionSpec properties


This step sets up our connectivity to the correct IMS system, which is
specified by Datastore.

168 Creating an Interactive B2B Web Application


1. In the Command Editor, select the Connector folder in the top left pane.
The connector beans appear in the top right pane.
2. Select the IMS interaction specification bean:
com.ibm.connector.imstoc.IMSInteractionSpec
3. Right-click the Datastore name property in the bottom pane, and choose
Promote Property. Figure 78 shows the promoted InteractionSpec
properties.

Figure 78. The imsemail IMS Interaction Specification properties

7.1.6.6 Promote the ConnectionSpec properties


To promote the Host name and Port properties:
1. Select the Connector folder in the top left pane. The connector beans
appear in the top right pane.
2. Select the IMS connection specification bean:
com.ibm.connector.imstoc.IMSConnectionSpec
3. Right-click the Host name property, and click Promote Property.

Chapter 7. Create the email servlet 169


4. Repeat the previous step to promote the Port property. Figure 79 shows
the promoted ConnectionSpec properties.

Figure 79. The imsemail IMS Connection Specification properties

7.2 Test the beans in the Websphere Test Environment


The command bean is accessible from either a command navigator bean, a
Java Server Page (JSP), or a servlet. In this step you create a simple JSP to
test the command bean you just built.

7.2.1 Create the test Java Server Page


1. Using an editor (such as Notepad), create a new text file, called
Imsbeancall.jsp, and save it in the following directory:
<vajpath>\ide\project_resources\IBM WebSphere Test
Environment\hosts\default_host\default_app\web\

170 Creating an Interactive B2B Web Application


Where, <vajpath> is the drive:\directory where you installed VisualAge for
Java.
2. Enter the code show in Figure 80.
Tip: This code is provided in \client\jsp\Imsbeancall.jsp where you
installed the demo files.

<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.0//EN”>


<HTML>
<HEAD>
</HEAD>
<BODY>

<jsp:useBean id=”bean01” class=”imsemail.EABexecutecmd”


scope=”page”></jsp:useBean>
<%
bean01.setIN__CUST__ID(1);
bean01.execute();
%>
<TABLE border=”0”>
<TR><TD>OUT__CUST__ID</TD>
<TD><%=bean01.getOUT__FIRST__NAME() %></TD>
</TR>
<TR><TD>OUT__LAST__NAME</TD>
<TD><%=bean01.getOUT__LAST__NAME() %></TD>
</TR>
<TR><TD>OUT__EMAIL__ID</TD>
<TD><%=bean01.getOUT__EMAIL__ID() %></TD>
</TR>
</TABLE>
</BODY>
</HTML>

Figure 80. Source of Imsbeancall.jsp

The returned values belonging to customer ID 1 will be displayed.

7.2.2 Run the Java Server Page locally


Use these steps to run the Java Server Page locally:
1. Start VisualAge for Java Websphere Test environment.
2. Open your browser window and type:
http://127.0.0.1:8080/Imsbeancall.jsp

Chapter 7. Create the email servlet 171


3. The output should look similar to Figure 81.

Figure 81. Imsbeancall.jsp browser output

7.3 Create the servlet and add email functionality


To be able to send email, you need a mail server. In this step, you get the
classes you need to act as the mail server, create a servlet, and insert the
code into the servlet to send the email.
1. Download the Javamail classes and the Javabeans Activation Framework
(jaf) classes from the Sun homepage, following the instructions on these
pages:
http://java.sun.com/products/javamail/
http://java.sun.com/products/javabeans/glasgow/jaf.html
2. Unpack the zip files you downloaded.
3. To import the class files into the project, from the VisualAge for Java
Workbench, right-click the imsemail package in the B2BApp project and
click Import. Check jar file, click Browse, and select:
activation.jar
mail.jar
4. Create a servlet to execute the EABexecutecmd command class you
created earlier.
Tip: Use the JavaBean wizard in WebSphere Studio and follow a similar
procedure to the one you used when you created the order, bid, and
accept servlets.

172 Creating an Interactive B2B Web Application


5. To make the javamail classes available to the servlet, include the code
shown in Figure 82.

import javax.mail.*;
import javax.mail.internet.*;

Figure 82. Import statements to use SUNs javamail

6. Then add the code in Figure 83 to the servlet after executing the
EABExecutecmd command bean (which retrieved the email address from
IMS):

//code to send email


String to, subject = null, from = null;
String mailhost = "smtp.company.com"; // your smtp mail server
String mailer = "sendmail servlet";
String protocol = null, host = null, user = null, password = null;
String record = null;// name of folder in which to record mail
try {
to = eABexecutecmd.getOUT__EMAIL__ID();
subject = "confirmation";
Properties props = System.getProperties();
props.put("mail.smtp.host", mailhost);
// Get a Session object
Session session = Session.getDefaultInstance(props, null);
// construct the message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("mailer@ads.imsmvs.ibm.com"));
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));
msg.setSubject(subject);
msg.setText("Dear " + eABexecutecmd.getOUT__FIRST__NAME() +
" " + eABexecutecmd.getOUT__LAST__NAME() + ",\n" +
"Your order will be expedited as promised.\n" +
"Thank you for shopping at AcmeStuff!");
msg.setHeader("X-Mailer", mailer);
msg.setSentDate(new Date());
// send the thing off
Transport.send(msg);
} catch (Exception e) {
e.printStackTrace();
}

Figure 83. Additional code to send email

Chapter 7. Create the email servlet 173


7. When you publish the servlet, add the javamail classes to the application
server classpath.
8. The email will look similar to Figure 84.

Please respond to mailer@ads.imsmvs.ibm.com


To:WEAVER@MVSIMS.IBM.COM
Subject: confirmation
Dear RICK WEAVER ,
Your order will be expedited as promised.
Thank you for shopping at AcmeStuff!

Figure 84. Generated email

174 Creating an Interactive B2B Web Application


Part 3. Creating the Web application

This last part tells how to join the four servlets to form an interactive Web
application, involving three interactions with a user. You also see reference
information that may be helpful to you, as you develop this and other Web
applications.

© Copyright IBM Corp. 2001 175


176 Creating an Interactive B2B Web Application
Chapter 8. Join the servlets

In this chapter you transform the discrete servlets into a single Web
application that allows the user to flow from one action to the next. You see
how to:
• Define a Web application in WebSphere Application Server, to consolidate
the related servlets
• Provide the interactive flow for the user, by modifying the JSP files
• Modify the generated servlets, to pass the data from one servlet to
another
• Optionally, enhance the user interface

8.1 Define a Web application in WebSphere Application Server


Start by defining an application to WebSphere Application Server on your
host. You specify a directory where you will place the files so that the
Application Server can find them and you specify some application settings.

On ADS, all the Web applications and servlets are under a higher level
directory called demos. We set up a directory for our Web application files
called b2bapp, as shown in Figure 85.

demos
b2bapp
html
servlets
accept
bid
imsemail
general
order

Figure 85. Web application directory structure

We deployed each bean package under the servlets directory. For example,
the order bean files went in demos/b2bapp/servlets/order. We published all
the servlet class files (for example, custorder.class) and associated servlet
definition files (for example, custorder.servlet) to
demos/b2bapp/servlets/general.

© Copyright IBM Corp. 2001 177


All the JSP files, images, and the AcmeStuff.html file went under an html
directory; that is, /demos/b2bapps/html.

To define the Web application, on your server, under Unix System Services,
find the WebSphere Application Server configuration file. On ADS, open
/demos/websphere.cnf. If you are not using ADS, check with your system
administrator.

Figure 86 shows the definition we used for our Web application on ADS.

########################################################
deployedwebapp.b2bapp.host=default_host
deployedwebapp.b2bapp.rooturi=/demos/b2bapp
deployedwebapp.b2bapp.classpath=/demos/b2bapp/servlets
deployedwebapp.b2bapp.documentroot=/demos/b2bapp
deployedwebapp.b2bapp.autoreloadinterval=10000
webapp.b2bapp.jspmapping=*.jsp
webapp.b2bapp.jsplevel=1.0
webapp.b2bapp.filemapping=*.html
webapp.b2bapp.filemapping=*.gif
webapp.b2bapp.servletmapping=/servlets
########################################################

Figure 86. Web application definition in WebSphere configuration file

• To indicate the location of the servlets, we set:


deployedwebapp.b2bapp.classpath=/demos/b2bapp/servlets
The classpath property specifies the classpath that the application level
class loader searches for a servlet when the system class loader cannot
find it. When the Application Server needs to load a servlet, it first
attempts to load it using a system class loader which is configured to
search the classpath defined in another statement in the configuration file:
appserver.classpath=...
If the system class loader can’t find the requested servlet, an application
specific class loader is used to locate and load the servlet, using the
classpath specified on the statement:
deployedwebapp.<webapp-name>.classpath=<value> property
• To indicate the location of the HTML, JSP, and image files, we set:
deployedwebapp.b2bapp.documentroot=/demos/b2bapp

178 Creating an Interactive B2B Web Application


The documentroot property is used to specify the fully qualified name of
the directory containing Java Server Pages, HTML, and static files that are
to be served by the Application Server.
• To specify the JSP level so that it is consistent with the properties for the
WebSphere Studio B2BApp project, we used:
webapp.b2bapp.jsplevel=1.0
• Because we were installing the application in a development and test
environment, not a production environment, we set:
deployedwebapp.b2bapp.autoreloadinterval=10000
In a production environment, you would typically not use the autoreload
property, which is specifies whether or not a Web application is to be
reloaded if changes are detected in the implementation file for one or more
servlets in this Web application.

For a more detailed discussion of the configuration file, see WebSphere


Application Server Standard Edition, Planning, Installing, and Using,
GC34-4806, which you can find at:
http://www.ibm.com/software/websphere/appserv/library_390.html

Scroll down the Web page to find the title. This book refers to the
configuration file as was.conf.

8.2 Provide the interactive flow


What we have developed so far is a set of discrete servlets. The user has to
open a different HTML page in the Web browser to run each one.
Furthermore, he has to remember data from the order and bid results pages
and re-key that data to run the accept servlet. The email servlet is isolated as
well. So first you modify the JSP results pages to allow the user to more
easily navigate from one servlet to the next servlet.

You probably want to copy the files before modifying them, so that gives us
the opportunity to provide more usable names. In Figure 87, we’ve illustrated
the overall flow of the application, using some new names that fit in with our
AcmeStuff company Web site.

Chapter 8. Join the servlets 179


AcmeStuff.html
CICS

V2CSTDB
DB2
GETORDRS CUSTOMER
ORDERS
order servlet
AcmeStuffOrder.jsp

MQ Shipper
1

Shipper
MQHUB 2

bid servlet
Shipper
AcmeStuffBids.jsp
3

Shipper
MQ 1

accept Shipper
MQHUB 2
servlet
AcmeStuffFinal.jsp
Shipper
3

MQ/CICS
Bridge CICS
IMS
imsemail ORUPDATE DB2
Transaction ORDERS
servlet
email Mgr
IMS
JAVATRAN Database Mgr
JAVADB

Figure 87. AcmeStuff Web application flow, from an internal perspective

8.2.1 Create the opening page


To create the first page for the Web application, you simply copy and rename
the order input page. You don’t have to make any changes to it, but we’ll add
a title, to easily differentiate it from our original.

If you don’t care about modifying the file, you could go to the host and copy
the file there.
1. Get into OMVS
2. To change to the correct directory, type:
cd /demos/b2bapp/html

180 Creating an Interactive B2B Web Application


3. To copy the file, type:
cp custorderHTMLInput.html AcmeStuff.html

If your WebSphere Application Server is set up so that it serves the html


(rather than the Web server, IBM HTTP Server), you won’t be able to edit it,
because it is stored in binary.

If you want to edit the file (for example, to insert a title), on your Windows
client:
1. Open WebSphere Studio.
1. Right-click custorderHTMLInput.html and click Copy.
2. Right-click the html directory and click Paste.
Copy-of-custorderHTMLInput.html is added to your Studio project in the
html directory.
3. Select Copy-1-of-custorderHTMLInput.html and click Edit->Rename.
4. Type: AcmeStuff.html
5. Edit AcmeStuff.html and insert the following title below the line containing
<HEAD>:
<TITLE>AcmeStuff Company</TITLE>
6. Save and close the file.
7. Right-click AcmeStuffOrder.jsp and click Check In.
8. Publish or FTP the AcmeStuff.html to /demos/b2bapp/html on your server
machine.
Tip: If your Web server expects HTML to be in binary, then FTP the file,
(instead of publishing it using Studio) will not send the file in binary. If your
Web server is not set up to expect binary, then you can use Studio to
publish it instead. If you are using ADS, you can publish using Studio.
9. Try out the new page by opening it in your Web browser.
http://<your server IP>/demos/b2bapp/html/AcmeStuff.html

It should look similar to Figure 88.

Chapter 8. Join the servlets 181


Figure 88. AcmeStuff input page, which starts the order servlet

8.2.2 Modify the order results page


Next, you modify custorderHTMLResults.jsp to allow the user to type in his
desired delivery date for his order and a button to start the bid servlet. You
will modify the JSP so it displays not only the customer and order information,
but also a new entry field for the date, a label, and Submit button. It will look
similar to Figure 89 for customer number 1.

182 Creating an Interactive B2B Web Application


Figure 89. Page produced from modified custorderHTMLResults.JSP

1. Following the procedure described above, in your WebSphere Studio


project, make a new copy of custorderHTMLResults.jsp and save it as
AcmeStuffOrder.jsp.
2. Double-click AcmeStuffOrder.jsp to edit it in your default editor.
3. To identify this new page, insert this title line immediately after the
<HEAD> tag:
<TITLE>AcmeStuff Company: Order</TITLE>
4. Scroll down to the bottom of the file.
5. Immediately above the </BODY> tag, insert the code shown in Figure 90.

Chapter 8. Join the servlets 183


<FORM METHOD="post" ACTION="/demos/b2bapp/servlets/general.shipbids">
<P>To expedite your order, enter new desired delivery date:
<INPUT TYPE="text" NAME="wantdate" ID="wantdate" SIZE="20"
MAXLENGTH="20" ></P>
<INPUT TYPE="hidden" NAME="mlname" ID="mlname" VALUE="HTML">
<P><INPUT TYPE="submit" NAME="Submit" ID="Submit" VALUE="Submit">
<INPUT TYPE="reset" NAME="Reset" ID="Reset" VALUE="Reset">
</P>
</FORM>

Figure 90. Code to provide bid servlet for input on order results page

The HTML form code above adds the date field and a Submit button to the
order servlet’s results page. The date field is preceded by the label:
To expedite your order, enter new desired delivery date:
When the user enters a date and clicks the Submit button, the shipbids
servlet in the general package gets control, and receives the date field,
which it knows as wantdate. The shipbids servlet is published in the
/demos/b2bapp/servlets directory on the Web server. Because you don’t
specify an IP address as part of the ACTION= clause of the FORM tag, the
server knows to look for the directory on the same machine.
6. Save and close AcmeStuffOrder.jsp.
7. Right-click AcmeStuffOrder.jsp and click Check In.

8.2.3 Modify the order servlet configuration file


The order servlet configuration file (custorder.servlet) tells the order servlet
(custorder.java) which file to use to format the results page. Currently, it says
to use /demos/b2bapp/html/custorderHTMLResults.jsp.

Because you have a new file for the results page, AcmeStuffOrder.jsp, you
need to update the order servlet configuration file.

In your Studio project:


1. Edit \general\custorder.servlet.
2. Change the <uri> tag value for the default page from
custorderHTMLResults.jsp to AcmeStuffOrder.jsp.It should look similar to
Figure 91.

184 Creating an Interactive B2B Web Application


...<default-page>
<uri>/demos/b2bapp/html/AcmeStuffOrder.jsp</uri>
</default page> ...

Figure 91. The custorder.servlet modified for AcmeStuffOrder.jsp as results page

3. Save and close custorder.servlet.


4. Right-click custorder.servlet and click Check In.

8.2.4 Modify the bid results page


Next, you modify shipbidsHTMLResults.jsp to add the order results retrieved
earlier by the order servlet, and to provide buttons for the user to select one
of the shipping options provided by the shipbids servlet. It will look like similar
to Figure 92 for customer number 1.

Chapter 8. Join the servlets 185


Figure 92. Page produced from modified shipbidsHTMLResults.jsp

1. Following the procedure described above, in your WebSphere Studio


project, make a new copy of shipbidsHTMLResults.jsp and save it as
AcmeStuffBids.jsp.
2. Double-click AcmeStuffBids.jsp to edit it in your default editor.
3. To identify this new page, insert this title line immediately after the
<HEAD> tag:
<TITLE>AcmeStuff Company: Shipping Bids</TITLE>
4. Scroll down to the bottom of the file.
5. Immediately above the </BODY> tag, insert the code shown in Figure 93.

186 Creating an Interactive B2B Web Application


<%@ page import="order.CICSRetrieveNavigator" %>
<jsp:useBean id="custorder" type="order.CICSRetrieveNavigator"
scope="session"></jsp:useBean>
<p>Customer Number: <%= custorder.getCustomerNumber() %><br>
<p>Shipping Address: </p>
<%= custorder.getCustomerFirstName() %> &nbsp;
<%= custorder.getCustomerLastName() %>
<%= custorder.getCustomerAddress() %><br>
<%= custorder.getCustomerCity() %><br>
<%= custorder.getCustomerState() %><br>
<%= custorder.getCustomerCountry() %><br>
<<TABLE border="1">
<TBODY>
<TR>
<TD>ItemNumber</TD>
<TD>Item</TD>
<TD>ItemCost</TD>
<TD>ShipDate</TD>
<TD>ShipCost</TD>
<TD>Shipper</TD>
</TR>
<TR>
<TD align="center"><%= custorder.getOrderItemNumber() %></TD>
<TD align="center"><%= custorder.getOrderItem() %></TD>
<TD align="center"><%= custorder.getOrderItemCost() %></TD>
<TD align="center"><%= custorder.getOrderShipDate() %></TD>
<TD align="center"><%= custorder.getOrderShipCost() %></TD>
<TD align="center"><%= custorder.getOrderShipper() %></TD>
</TR>
</TBODY>
</TABLE>

Figure 93. Code to add order results to bids results page

You use this code to access the custorder bean stored in the session object.
You reference the properties on the navigator to get the customer and order
information retrieved by the order servlet. For example, to get the customer’s
address, you code:
<%= custorder.getCustomerAddress() %>

We placed the values into tables just to separate the customer information
and order information and to make the data a little easier to read. Also, we
were preparing the files to hand over to a graphics designer and wanted to
get the fields in approximately the positions the designer was expecting them.

Chapter 8. Join the servlets 187


You can place the values inside any valid HTML. If you want to make the page
more appealing, you could work with a graphics designer, as we have done
for the interface shown in Chapter 3, “About the server configuration” on
page 23 and described in 8.4, “Optionally, enhance the user interface” on
page 197.

To place the shipbids results in a table, you can replace the shipbids code
with the code shown in Figure 94. We removed the comments to make the
code easier to read.

<%@ page import="bid.BidsNavigator" %>


<jsp:useBean id="allbids" type="bid.BidsNavigator"
scope="session"></jsp:useBean>
<TABLE border="3">

<TR>
<TD>Shipper</TD>
<TD>Closest Delivery Date</TD>
<TD>Additional Cost</TD>
</TR>
<TR>
<TD><%= allbids.getBidder1() %></TD>
<TD><%= allbids.getBid1date() %></TD>
<TD><%= allbids.getBid1cost() %></TD>
</TR>
<TR>
<TD> <%= allbids.getBidder2() %></TD>
<TD><%= allbids.getBid2date() %></TD>
<TD><%= allbids.getBid2cost() %></TD>
</TR>
<TR>
<TD><%= allbids.getBidder3() %></TD>
<TD><%= allbids.getBid3date() %></TD>
<TD><%= allbids.getBid3cost() %></TD>
</TR>
</TABLE>

Figure 94. Code to modify the presentation of the bids results

Now add the code shown in Figure 95 to call the accept servlet. In a form, you
add three buttons, one for each of the shipping options, and you call the
servlet with the POST method.

188 Creating an Interactive B2B Web Application


<FORM method="POST" action="/demos/b2bapp/servlets/general.acceptdate">
<INPUT type="submit" id="AcceptBidder" name="AcceptBidder"
value="Accept Bidder1">
<INPUT type="submit" id="AcceptBidder" name="AcceptBidder"
value="Accept Bidder2">
<INPUT type="submit" id="AcceptBidder" name="AcceptBidder"
value="Accept Bidder3"></FORM>

Figure 95. Code to add the accept servlet invocation

8.2.5 Modify the bid servlet configuration file


The bid servlet configuration file (shipbids.servlet) tells the bid servlet
(shipbids.java) which file to use to format the results page. Currently, it says
to use /demos/b2bapp/html/shipbidsHTMLResults.jsp.

Because we have a new file for the results page, AcmeStuffBids.jsp, we need
to update the bid servlet configuration file.

In your Studio project:


1. Edit \general\shipbids.servlet.
2. Change the <uri> tag value for the default page from
shipbidsHTMLResults.jsp to AcmeStuffBids.jsp. It should look similar to
Figure 96.

...<default-page>
<uri>/demos/b2bapp/html/AcmeStuffBids.jsp</uri>
</default page> ...

Figure 96. The shipbids.servlet, modified for AcmeStuffBids.jsp as results page

3. Save and close shipbids.servlet.


4. Right-click shipbids.servlet and click Check In.

8.2.6 Modify the accept results page


Next, you modify acceptdateHTMLResults.jsp to:
• Add some fields retrieved earlier by the order servlet.
• Provide some text to go along with the confirmation code.
• Call the email servlet.

Chapter 8. Join the servlets 189


The page produced by the modified accept results page will look like similar
to Figure 97 for customer number 1.

Figure 97. Page produced from modified accept servlet results page

1. In your WebSphere Studio project, make a new copy of


acceptdateHTMLResults.jsp and save it as AcmeFinal.jsp.
2. Double-click AcmeFinal.jsp to edit it in your default editor.
3. To identify this new page, insert this title line immediately after the
<HEAD> tag:
<TITLE>AcmeStuff Company: Confirmation</TITLE>
4. Scroll down to the bottom of the file.
5. Immediately above the </BODY> tag, insert the code shown in Figure 98,
which will display the confirmation and invoke the email bean. (If you
created a servlet, you could invoke it instead).

190 Creating an Interactive B2B Web Application


<%@ page import="accept.AcceptNavigator" %>
<jsp:useBean id="accnav" type="accept.AcceptNavigator"
scope="session"></jsp:useBean>
<%@ page import="order.CICSRetrieveNavigator" %>
<jsp:useBean id="custorder" type="order.CICSRetrieveNavigator"
scope="session"></jsp:useBean>
Customer Number: <%= custorder.getCustomerNumber() %><br>
<p>Congratulations, <%= custorder.getCustomerFirstName() %> <%=
custorder.getCustomerLastName() %>!
Your expedited order is confirmed. <br>
Your confirmation code is: <b> <%= accnav.getBothConf() %></b></p>
<p>Your
<b><%= custorder.getOrderItem() %></b> will be delivered on
<b><%= accnav.getOrderShipDate() %></b> by
<b><%= accnav.getOrderShipper() %></b> for an additional charge of
<b><%= accnav.getOrderShipCost() %></b>, to this address:
<p><%= custorder.getCustomerAddress() %><br>
<%= custorder.getCustomerCity() %><br>
<%= custorder.getCustomerState() %><br>
<%= custorder.getCustomerCountry() %></p>
<jsp:useBean id=”bean01” class=”imsemail.EABexecutecmd”
scope=”page”></jsp:useBean>
<%
bean01.setIN__CUST__ID(<%= custorder.getCustomerNumber() %>);
bean01.execute();
%>

Figure 98. Code to customize accept servlet

8.2.7 Modify the accept servlet configuration file


Just as you did for the order and bid servlets, you need to modify the accept
servlet configuration file (acceptdate.servlet) to tell the accept servlet
(acceptdate.java) which file to use to format the results page.

In your Studio project:


1. Edit \general\acceptdate.servlet.
2. Change the <uri> tag value for the default page from
acceptdateHTMLResults.jsp to AcmeStuffFinal.jsp. It should look similar to
Figure 99.

Chapter 8. Join the servlets 191


...<default-page>
<uri>/demos/b2bapp/html/AcmeStuffFinal.jsp</uri>
</default page> ...

Figure 99. The acceptdate.servlet modified for AcmeStuffFinal.jsp as results page

3. Save and close acceptdate.servlet.


4. Right-click acceptdate.servlet and click Check In.

8.3 Modify the generated servlets to pass the data


In this section you make the changes required to the servlets to save and
retrieve data. For example, you see how to save the retrieved order data so
the bid servlet can display it and the accept servlet can use it to make the
shipping updates in the ORDERS table.

8.3.1 Understanding the order servlet


When you created the order servlet, using the JavaBean Wizard in Studio,
you answered Yes to the question:
Do you want to use the bean on more than one page?

Studio generated the code in the servlet file to create a session object to
store the order data.

In Studio, open the custorder.java file in the general directory and look
through the code as we explain some of the relevant parts.

The servlet classes are imported:


import com.ibm.webtools.runtime.*; // contains StudioPervasiveServlet
import java.io.*;
import javax.servlet.* //primary servlet classes
import javax.servlet.http.*; //contains HttpServlet and HttpSession
import com.ibm.connector.infrastructure.*; // CCF classes
import com.ibm.connector.infrastructure.java.*;// more CCF classes
import order.CICSRetrieveNavigator; // your navigator bean class

Your order servlet, which you named custorder, extends


StudioPervasiveServlet, which is an eventual extension of HttpServlet.
public class custorder extends
com.ibm.webtools.runtime.StudioPervasiveServlet
implements Serializable

192 Creating an Interactive B2B Web Application


In the performTask method, a session object is created.
HttpSession session = request.getSession(true);

Your custorder bean, the name you specified for the object, is created and
stored in the session.
// instantiate the beans and store them so they can be accessed by the
called page
order.CICSRetrieveNavigator custorder = new order.CICSRetrieveNavigator();
session.putValue("custorder", custorder);

The custorder bean and all its properties are bound to the session and
persists through the Web application. The servlet gets the customer number
from the HttpServletRequest object and loads it into the custorder bean.
if ((!getParameter(request, "customerNumber", true, true, true,
null).equals("")) &&
(!getParameter(request, "customerNumber", true, true, true,
null).equals("null")))
custorder.setCustomerNumber(Integer.valueOf(getParameter(request,
"customerNumber", true, true, true, null)).intValue());

When the execute method is called, the custorder bean executes the
CICSRetrieveNavigator which retrieves the data and stores the values (such
as, customer last name, customer first name, order item number, shipper, and
so on) into the custorder beans properties.
custorder.execute(new com.ibm.ivj.eab.command.CommandEvent(custorder));

The servlet calls the default page(AcmeStuffOrder.jsp), specified in its servlet


configuration file (custorder.servlet) to format and display the results.
// 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);

The custorder object is accessed directly by the AcmeStuffBids.jsp. It is also


used by the accept servlet. You do not need to make any changes to the
order servlet.

8.3.2 Understanding the bid servlet


Next open the shipbids.java file, also in the general directory, in Studio. The
bid servlet imports the bids navigator bean:
import bid.BidsNavigator;

Your bid servlet class, named shipbids, also extends StudioPervasiveServlet:

Chapter 8. Join the servlets 193


public class shipbids extends
com.ibm.webtools.runtime.StudioPervasiveServlet implements Serializable

The shipbids class creates a session object, instantiates the bean which you
named allbids, and binds the bean to the session.gets the wantdate
parameter from the HttpServletRequest object, and executes the navigator.
HttpSession session = request.getSession(true);

// instantiate the beans and store them so they can be accessed by the
called page
bid.BidsNavigator allbids = new bid.BidsNavigator();
session.putValue("allbids", allbids);

Then it gets the wantdate parameter from the HttpServletRequest object, and
executes the navigator.
allbids.setWantdate(getParameter(request, "wantdate", true, true, true,
null));

allbids.execute(new com.ibm.ivj.eab.command.CommandEvent(allbids));

The results are stored in the allbids bean properties.

The servlet calls the default page(AcmeStuffBids.jsp), specified in its servlet


configuration file (shipbids.servlet) to format and display the results.
// 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);

We will use the allbids object later in the accept servlet. You do not need to
make any changes to the bid servlet.

8.3.3 Modifying the accept servlet


Next open the acceptdate.java file, also in the general directory, in Studio.
The accept servlet imports the accept navigator bean:
import accept.AcceptNavigator;

Since we need to also access the order navigator and the bids navigator, add
the following import statements:
import order.CICSRetrieveNavigator;
import bid.BidsNavigator;

194 Creating an Interactive B2B Web Application


Your accept servlet class, named acceptdate, also extends
StudioPervasiveServlet:
public class acceptdate extends
com.ibm.webtools.runtime.StudioPervasiveServlet implements Serializable

The acceptdate class creates a session object, instantiates the bean which
you named accnav, and binds the bean to the session.
HttpSession session = request.getSession(true);

// instantiate the beans and store them so they can be accessed by the
called page
accept.AcceptNavigator accnav = new accept.AcceptNavigator();
session.putValue("accnav", accnav);

Then it gets the customerNumber and the other four parameters


(orderItemNumber, orderShipCost, orderShipDate, orderShipper) from the
HttpServletRequest object, and executes the navigator. However, you want to
get this information from the order and bid servlets.

Comment out the code that gets all five parameters.


// Initialize the bean customerNumber property from the parameters
// if ((!getParameter(request, "customerNumber", true, true, true,
null).equals("")) &&
// (!getParameter(request, "customerNumber", true, true, true,
null).equals("null")))
// accnav.setCustomerNumber(Integer.valueOf(getParameter(request,
"customerNumber", true, true, true, null)).intValue());
...
// accnav.setOrderShipper(getParameter(request, "orderShipper", true, true,
true, null));

8.3.3.1 Getting the order servlet data


Create an order navigator object so you can access the custorder bean and
get access to the navigator properties.
order.CICSRetrieveNavigator acustorder = new order.CICSRetrieveNavigator();
acustorder = (CICSRetrieveNavigator) session.getValue("custorder");

Load the accept navigator customerNumber property from the order bean’s
customerNumber property.
accnav.setCustomerNumber(acustorder.getCustomerNumber());

Chapter 8. Join the servlets 195


Load the accept navigator orderItemNumber property from the order bean’s
orderItemNumber property.
accnav.setOrderItemNumber (acustorder.getOrderItemNumber ());

8.3.3.2 Getting the bid servlet data


Create a bid navigator object so you access the allbids bean in the session
object and get access to the navigator properties.
bid.BidsNavigator thebids = new bid.BidsNavigator();
thebids = (BidsNavigator) session.getValue("allbids");

Determine which button the customer clicked and load the appropriate bid
data:
String whichbidder;
whichbidder = getParameter(request, "AcceptBidder", true, true, true,
null);
if (whichbidder.equals("Accept Bidder1")) {
accnav.setOrderShipCost(thebids.getBid1cost());
accnav.setOrderShipDate(thebids.getBid1date());
accnav.setOrderShipper(thebids.getBidder1());
} else

if (whichbidder.equals("Accept Bidder2")) {
accnav.setOrderShipCost(thebids.getBid2cost());
accnav.setOrderShipDate(thebids.getBid2date());
accnav.setOrderShipper(thebids.getBidder2());
} else

if(whichbidder.equals("Accept Bidder3")) {
accnav.setOrderShipCost(thebids.getBid3cost());
accnav.setOrderShipDate(thebids.getBid3date());
accnav.setOrderShipper(thebids.getBidder3());
}

Leave the rest of the code unchanged; that is, the code that sets the message
code and the message source, executes the accept navigator and calls the
default page to display the results.

8.3.4 Publish and test the Web application files


In WebSphere Studio, check in, then select and republish all the files you
changed.

196 Creating an Interactive B2B Web Application


Test the application by opening the following in your Web browser.
http://<server IP address>/demos/b2bapp/html/AcmeStuff.html

8.4 Optionally, enhance the user interface


If you want to make your Web application look like it does in 3.1, “About the
application flow” on page 23, ask your graphics designer (a very important
part of your Web application development team) to create a company look
and feel for your Web site. Give the designer your HTML and JSP files to add
in the customized formatting and logos. Then republish the HTML and JSP
and any images (in GIF or JPG) format in the /demos/b2bapp/html directory.

8.5 Considerations for developing your own Web applications


We’ve tried to provide you with a model for developing your own B2B Web
application, by demonstrating the overall tasks and using the major tools and
components that may be involved, particularly if you plan to use (at least in
part) an S/390 environment.

We developed this application with the tools available at the point in time we
had to do this project. You may have access to newer versions of the tools,
and you may even have new tools. Hopefully, you can use at least some of the
procedures and models you have learned here and adapt them to your
application, tools, and environment.

At publishing time, we are aware of one limitation that you would need to
consider if you chose to use WebSphere Application Server Version 3.5 for
OS/390 (which is now available). This release does not support the MQ
Connector. Therefore, to recreate this scenario, you would need to develop
the Java beans that put messages to put and get messages from the Hub
application.

One alternative is to use the MQ base classes and the bindings connection to
develop the Java beans that put messages to and get messages from the Hub
application. The base classes are available from the MQ support site, as a
downloadable MQSeries SupportPac, (currently known as MQSeries for
MVS/ESA - MQSeries classes for Java 1.0.3, SupportPac MA1G) at:
http://www.ibm.com/software/mqseries/

See MQSeries Using Java, SC34-5456, for more information and examples of
using MQ base Java classes.

Chapter 8. Join the servlets 197


Alternatively, you may want to consider using Java Message Service (JMS),
the emerging J2EE standard API for enterprise messaging. Consult the
documentation for the releases of WebSphere Application Server and MQ
Server you intend to use to determine your options.

198 Creating an Interactive B2B Web Application


Chapter 9. Troubleshooting

This chapter provides some help in resolving problems you may encounter
developing the Web application. Table 51 shows symptoms and possible
explanations for problems that may occur as you reconstruct this scenario.
Table 51. Symptom table

Symptom Possible cause Probable solution

Confirmation code = Invalid shipper entered Rerun and be sure to enter


ERROR, when running in Shipper field SHIPPER1, SHIPPER2, or
the accept servlet SHIPPER3 for the shipper field.
Must be all caps.

No response from the Hub and Shipper On ADS, look under SDSF-DA
servlets applications not running for the following jobids:
MQSHIP1
MQSHIP2
MQSHIP3
MQHUBCPP
If they are not there, submit these
jobs and then retry the servlets:
DEMOS.MQB2B.JCL(SHIPR1GO)
DEMOS.MQB2B.JCL(SHIPR2GO)
DEMOS.MQB2B.JCL(SHIPR3GO)
DEMOS.MQB2B.CPPJCL(MQHUBGO)

MJE001: Completion URL or host name not In VisualAge for Java, use the
Code 2, Reason 2059, correct in the command Command Editor to reset the
when attempting to test beans and navigator Host Name property in the
accept or bid servlet ConnectionSpec for each of the
two command beans and the
navigator. Applies to the bid
beans and accept beans.

Trying to run either the Known problem on Check WebSphere Application


bid or accept servlet, some releases of Server PROCESS files
the response page WebSphere Application (SYSPRINT and SYSOUT) to
reads: An error has Server determine release level. If it is
occurred. Please higher than WAS 3.02, Service
contact our support Level 3, the bid and accept
center. servlets will not run, because the
MQ Connector is not supported
beyond that level. See 8.5,
“Considerations for developing
your own Web applications” on
page 197.

© Copyright IBM Corp. 2001 199


Symptom Possible cause Probable solution

Error 500, jsp Java source for the Java Remove Java source (.java files)
compilation error beans and navigator from that directory
when running one of the were deployed to WAS
servlets on 390 under and reside in same dir
WAS, and IMWEBSRV with .class files
SYSPRINT or SYSOUT
says something like
AcceptNavigator does
not contain nested type
accept.AcceptNavigator

200 Creating an Interactive B2B Web Application


Appendix A. Server applications reference information

This chapter provides reference information that pertains to the server


applications.

A.1 Message syntax


This section provides the message syntax for the messages that are
exchanged among the servlets, the Hub application, and the shipper
applications.

A.1.1 Bid messages


Table 52 shows the BID type message. This message is constructed by the
bid servlet and put on the HUBREQQ for the Hub application, whenever the
bid servlet needs shipping bids.
Table 52. Bid servlet request to Hub, requesting shipping bids, on HUBREQQ

Field Length Meaning

BID 8 Message type

SERVLET 8 Message source

MM/DD/YYYY 10 Desired shipping


date

Table 53 shows the BID type message which the Hub application forwards to
the shipper applications by placing it on each of the Shipper request queues.
Table 53. Hub request to each shipper, requesting a shipping bid, on SxREQQ

Field Length Meaning

BID 8 Message type

MQHUB 8 Message source

MM/DD/YYYY 10 Desired shipping


date

© Copyright IBM Corp. 2001 201


Table 54 shows the ABID reply message format from a shipper application. It
is placed on the Hub’s response queue. It represents the shippers bid for
delivering the order on the customer’s target date.
Table 54. A shipper reply to Hub, providing a shipping bid, on HUBRESQ

Field Length Meaning

ABID 8 Message type

SHIPPERx 8 Message source

MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item

XX.XX 8 Additional shipping charge

Table 55 shows the ALLBIDS reply message format that the Hub application
returns to the servlet. The Hub places this message on the Hub reply queue,
HUBREPQ. It contains a consolidation of all the shippers’ ABID messages.
Table 55. Hub reply to bid servlet, providing all shipping bids, on HUBREPQ

Field Length Meaning

ALLBIDS 8 Message type

MQHUB 8 Message source

SHIPPERx 8 A shipper code (x=1, 2, or 3)

MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item

XX.XX 8 Additional shipping charge

SHIPPERx 8 A shipper code (x=1, 2, or 3)

MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item

XX.XX 8 Additional shipping charge

SHIPPERx 8 A shipper code (x=1, 2, or 3)

MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item

XX.XX 8 Additional shipping charge

202 Creating an Interactive B2B Web Application


A.1.2 Accept messages
Table 56 shows the ACCEPT message format. The accept servlet places this
message on the Hub’s request queue, HUBREQQ, when a customer chooses
one of the shipping bids.
Table 56. Accept servlet request message to Hub, on HUBREQQ

Field Length Meaning

ACCEPT 8 Message type

SERVLET 8 Message source

NNNNN 5 Customer number

MMMMM 5 Item number

MM/DD/YYYY 10 Chosen shipping date

SHIPPERx 8 Chosen shipper

XX.XX 8 New shipping charge

Table 57 shows the ACCEPT message format passed by the Hub to the
shipper whose bid was selected by the customer. The only difference in this
ACCEPT message format, compared to the ACCEPT message sent by the
servlet (Table 56) is the Message source.
Table 57. Accept message from Hub to Shipperx, on SxREQQ

Field Length Meaning

ACCEPT 8 Message type

MQHUB 8 Message source

NNNNN 5 Customer number

MMMMM 5 Item number

MM/DD/YYYY 10 Chosen shipping date

SHIPPERx 8 Chosen shipper

XX.XX 8 New shipping charge

Appendix A. Server applications reference information 203


Table 58 shows the REJECT message format which is constructed by the
Hub to notify the two shippers whose bids were not accepted by the
customer.
Table 58. Reject message from Hub to each Shipper, on SxREQQ

Field Length Meaning

REJECT 8 Message type

MQHUB 8 Message source

SHIPPERx 8 Chosen shipper

NNNNN 5 Customer number

MMMMM 5 Item number

MM/DD/YYYY 10 Chosen shipping date

SHIPPERx 8 Chosen shipper

XX.XX 8 New shipping charge

Table 59 shows the message format passed by the Hub to the MQ/CICS
Bridge to initiate the ORUPDATE application in CICS. The ORUPDATE
application updates the ORDERS table with the customer’s selected shipping
bid information.
Table 59. From Hub to MQ/CICS Bridge, on SYSTEM.C001.BRIDGE.QUEUE

Field Length Meaning

ORUPDATE 8 Message type

MQHUB 8 Message source

NNNNN 5 Customer number

MMMMM 5 Item number

MM/DD/YYYY 10 Chosen shipping date

SHIPPERx 8 Chosen shipper

XX.XX 8 New shipping charge

204 Creating an Interactive B2B Web Application


Table 60 shows the ACCEPTOK message format provided by the winning
shipper to the Hub to confirm that the shipper received the ACCEPT
notification and will deliver the item as promised.
Table 60. Reply message from Shipperx to Hub, on HUBRESQ

Field Length Meaning

ACCEPTOK 8 Message type

SHIPPERx 8 Message source

Table 61 shows the message format provided by the Hub to the accept servlet
to indicate whether or not the order can be delivered according to the
customer’s selection.
Table 61. Reply message from Hub to accept servlet, on HUBREPQ

Field Length Meaning

BOTHCONF or 8 Message type


ERROR

MQHUB 8 Message source

A.2 Server application quick reference


Table 62 tells where to find the source of the server applications on ADS. You
can also use it to map to the source provided in the demo files. See
Appendix B, “Using the additional material” on page 207 for information on
acquiring the demo files.

The zip file hierarchy maps to the dataset hierarchy. For example, to find
DEMOS.MQB2B.CPPPROG(MQHUB), look in \demos\mqb2b\cppprog for a
file named mqhub.
Table 62. Server component source on ADS

Application Source language Source file

MQHUB C++/MQ DEMOS.MQB2B.CPPPROG(MQHUB)

MQSHIPR1 COBOL/MQ DEMOS.MQB2B.COBOL(SHIPR1)

MQSHIPR2 COBOL/MQ DEMOS.MQB2B.COBOL(SHIPR2)

MQSHIPR3 COBOL/MQ DEMOS.MQB2B.COBOL(SHIPR3)

V2CSTDB COBOL/CICS/DB2 DEMOS.EBUS.JCL(V2CSTDB)

GETORDRS COBOL/CICS/DB2 DEMOS.MQB2B.JCL(ORDRJOB)

Appendix A. Server applications reference information 205


Application Source language Source file

ORUPDATE COBOL/CICS/DB2 DEMOS.MQB2B.COBOL(UPDATJOB)

JAVATRAN COBOL/IMS DEMOS.IMS.SOURCE(JAVAPGM)

206 Creating an Interactive B2B Web Application


Appendix B. Using the additional material

This redbook contains additional material on the Web. This section tells how
to acquire and use the material.

B.1 Locating the additional material on the Internet


The Web material associated with this redbook is available in softcopy on the
Internet from the IBM Redbooks Web server. Point your Web browser to:

ftp://www.redbooks.ibm.com/redbooks/SG246221

Alternatively, you can go to the IBM Redbooks Web site at:

ibm.com/redbooks

Select the Additional materials and open the directory that corresponds with
the redbook form number.

B.2 Using the Web material


The additional Web material that accompanies this redbook is a set of demo
files in a single zip file:
File name Description
demos6221.zip Zipped code samples

B.2.1 System requirements for downloading the Web material


The material is less than 300K zipped, and about 1.6MB unzipped. The
following system configuration is recommended for using the demo files:
Hard disk space: 3 MB
Operating System: Windows NT 4.0, with Service Pack 4 or higher
Processor: 233 MHz
Memory: 192 MB

B.2.2 How to use the material


1. Download the zip file to your workstation.
2. Create a folder on your workstation and extract the contents of the file into
that folder.
3. In Part 1, as you read Chapter 3, “About the server configuration” on
page 23, refer to the files in these directories to get a deeper

© Copyright IBM Corp. 2001 207


understanding of the configuration. The directories mimic the host naming
hierarchy.
\democics
\demos
\mqm
The directories mimic the host naming hierarchy. For example:
demos\mqb2b\jcl
On the ADS system on OS/390, this refers to:
DEMOS.MQB2B.JCL
4. In Part 2, when you create the four servlets, use the files in this directory
as input to create COBOL record types:
\client

208 Creating an Interactive B2B Web Application


Appendix C. Special notices

This publication is intended to help Application Programmers to create Web


applications. The information in this publication is not intended as the
specification of any programming interfaces that are provided by VisualAge
for Java, WebSphere Studio, WebSphere Application Server, DB2, IMS,
MQSeries, or CICS. See the PUBLICATIONS section of the IBM
Programming Announcement for these products for more information about
what publications are considered to be product documentation.

References in this publication to IBM products, programs or services do not


imply that IBM intends to make these available in all countries in which IBM
operates. Any reference to an IBM product, program, or service is not
intended to state or imply that only IBM's product, program, or service may be
used. Any functionally equivalent program that does not infringe any of IBM's
intellectual property rights may be used instead of the IBM product, program
or service.

Information in this book was developed in conjunction with use of the


equipment specified, and is limited in application to those specific hardware
and software products and levels.

IBM may have patents or pending patent applications covering subject matter
in this document. The furnishing of this document does not give you any
license to these patents. You can send license inquiries, in writing, to the IBM
Director of Licensing, IBM Corporation, North Castle Drive, Armonk, NY
10504-1785.

Licensees of this program who wish to have information about it for the
purpose of enabling: (i) the exchange of information between independently
created programs and other programs (including this one) and (ii) the mutual
use of the information which has been exchanged, should contact IBM
Corporation, Dept. 600A, Mail Drop 1329, Somers, NY 10589 USA.

Such information may be available, subject to appropriate terms and


conditions, including in some cases, payment of a fee.

The information contained in this document has not been submitted to any
formal IBM test and is distributed AS IS. The use of this information or the
implementation of any of these techniques is a customer responsibility and
depends on the customer's ability to evaluate and integrate them into the
customer's operational environment. While each item may have been
reviewed by IBM for accuracy in a specific situation, there is no guarantee
that the same or similar results will be obtained elsewhere. Customers

© Copyright IBM Corp. 2001 209


attempting to adapt these techniques to their own environments do so at their
own risk.

Any pointers in this publication to external Web sites are provided for
convenience only and do not in any manner serve as an endorsement of
these Web sites.

The following terms are trademarks of the International Business Machines


Corporation in the United States and/or other countries:
AS/400 OpenEdition
400 OS/390
AT Redbooks
CICS Redbooks Logo
CT RS/6000
Current S/390
DB2 SP
DRDA SP1
e (logo)® SupportPac
IBM ® System/390
IBM.COM TCS
IMS/ESA VisualAge
Lotus VTAM
MQSeries WebSphere
MVS/ESA Wizard
Netfinity

The following terms are trademarks of other companies:

Tivoli, Manage. Anything. Anywhere.,The Power To Manage., Anything.


Anywhere.,TME, NetView, Cross-Site, Tivoli Ready, Tivoli Certified, Planet
Tivoli, and Tivoli Enterprise are trademarks or registered trademarks of Tivoli
Systems Inc., an IBM company, in the United States, other countries, or both.
In Denmark, Tivoli is a trademark licensed from Kjøbenhavns Sommer - Tivoli
A/S.

C-bus is a trademark of Corollary, Inc. in the United States and/or other


countries.

Java and all Java-based trademarks and logos are trademarks or registered
trademarks of Sun Microsystems, Inc. in the United States and/or other
countries.

Microsoft, Windows, Windows NT, and the Windows logo are trademarks of
Microsoft Corporation in the United States and/or other countries.

210 Creating an Interactive B2B Web Application


PC Direct is a trademark of Ziff Communications Company in the United
States and/or other countries and is used by IBM Corporation under license.

ActionMedia, LANDesk, MMX, Pentium and ProShare are trademarks of Intel


Corporation in the United States and/or other countries.

UNIX is a registered trademark in the United States and other countries


licensed exclusively through The Open Group.

SET, SET Secure Electronic Transaction, and the SET Logo are trademarks
owned by SET Secure Electronic Transaction LLC.

Other company, product, and service names may be trademarks or service


marks of others.

Appendix C. Special notices 211


212 Creating an Interactive B2B Web Application
Appendix D. Related publications

The following publications and Internet addresses may be useful if you decide
to implement your own application.

D.1 IBM Redbooks


For information on ordering these publications see “How to get IBM
Redbooks” on page 217.
• Design and Implement Servlets, JSPs, and EJBs for IBM WebSphere
Application Server, SG24-5754
• e-business Enablement Cookbook for OS/390 Volume III: Java
Development, SG24-5980
• Enterprise JavaBeans Development Using VisualAge for Java, SG24-5429
• OS/390 TCP/IP OpenEdition Implementation Guide, SG24-2141
• Programming with VisualAge for Java Version 3.5, SG24-5264
• Servlet and JSP Programming with IBM WebSphere Studio and VisualAge
for Java, SG24-5755
• Version 3.5 Self Study Guide: VisualAge for Java and WebSphere Studio,
SG24-6136
• VisualAge for Java Enterprise Version 3: Persistence Builder with GUIs,
Servlets, and Java Server Pages, SG24-5426

D.2 IBM Redbooks collections


Redbooks are also available on the following CD-ROMs. Click the CD-ROMs
button at ibm.com/redbooks for information about all the CD-ROMs offered,
updates and formats.
CD-ROM Title Collection Kit
Number
IBM System/390 Redbooks Collection SK2T-2177
IBM Networking Redbooks Collection SK2T-6022
IBM Transaction Processing and Data Management Redbooks Collection SK2T-8038
IBM Lotus Redbooks Collection SK2T-8039
Tivoli Redbooks Collection SK2T-8044
IBM AS/400 Redbooks Collection SK2T-2849
IBM Netfinity Hardware and Software Redbooks Collection SK2T-8046
IBM RS/6000 Redbooks Collection SK2T-8043
IBM Application Development Redbooks Collection SK2T-8037
IBM Enterprise Storage and Systems Management Solutions SK3T-3694

© Copyright IBM Corp. 2001 213


D.3 Other resources
These publications are also relevant as further information sources:
• Building servlets with session tracking, a tutorial by Jeanne Murray.
Available from IBM developerWorks:
http://www.ibm.com/developerworks/
Select Tutorials and Training. In the Technology Integration field, select
the pull-down list, and then select the tutorial Building servlets with
session tracking.
• IMS Connect Guide and Reference, SC27-0946, which can also be found at:
http://www.ibm.com/software/data/db2imstools/details/
• Java Programming: Advanced Topics, by Joe Wigglesworth and Paul
McMillan, published by Thomson Learning, ISBN 0-7600-1098-6 (IBM form
number SR23-9631)
• VisualAge for Java, Version 3.5, IMS Connector for Java User’s Guide,
available from VisualAge Developer’s Domain:
http://www.ibm.com/vadd/
Click Library -> Product documentation (PDFs)-> IBM VisualAge for
Java 3.5 PDF Documentation. Scroll down the page to the Accessing
transaction systems [ENTERPRISE] section. Find IMS Connector for
Java User's Guide.
• IMS TOC Connector for Java User’s Guide, available from VisualAge
Developer’s Domain:
http://www.ibm.com/vadd/
Click Library -> Product documentation (PDFs)-> IBM VisualAge for
Java 3.02 PDF Documentation. Scroll down the page to the Accessing
transaction systems [ENTERPRISE] section. Find IMS TOC Connector
for Java User's Guide.
• WebSphere Application Server Standard Edition Planning, Installing, and
Using, available from:
http://www.ibm.com/software/websphere/appserv/library_390.html
Scroll down the Web page to find the title.
• MQSeries Using Java, SC34-5456

214 Creating an Interactive B2B Web Application


D.4 Referenced Web sites
These Web sites are also relevant as further information sources:
• http://www.ibm.com/software/cics/ CICS home page
• http://www.ibm.com/software/cobol/ COBOL home page
• http://www.ibm.com/software/db2/os390/ DB2 for OS/390 home page
• http://www.ibm.com/developerworks/ IBM developerWorks home page
• http://www.ibm.com/software/data/ims/ IMS home page
• http://www.ibm.com/software/mqseries/ MQSeries home page
• http://www.ibm.com/software/ad/vajava/ VisualAge for Java home page
• http://java.sun.com/products/javamail/ Sun Microsystems JavaMail API
• http://www.ibm.com/websphere/ WebSphere home page
• http://www.ibm.com/vadd/ VisualAge Developer Domain page
• http://www.ibm.com/software/data/db2imstools/details/
IBM Data Management Tools for OS/390 and z/OS
• http://java.sun.com/products/javabeans/glasgow/jaf.html
Sun Microsystems JavaBeans Activation Framework extension
• http://www.ibm.com/s390/ads
WebSphere Application Development Solution home page
• http://www.ibm.com/software/websphere/appserv/library_390.html
WebSphere for OS/390 documentation page

Appendix D. Related publications 215


216 Creating an Interactive B2B Web Application
How to get IBM Redbooks

This section explains how both customers and IBM employees can find out about IBM Redbooks,
redpieces, and CD-ROMs. A form for ordering books and CD-ROMs by fax or e-mail is also provided.
• Redbooks Web Site ibm.com/redbooks
Search for, view, download, or order hardcopy/CD-ROM Redbooks from the Redbooks Web site.
Also read redpieces and download additional materials (code samples or diskette/CD-ROM images)
from this Redbooks site.
Redpieces are Redbooks in progress; not all Redbooks become redpieces and sometimes just a few
chapters will be published this way. The intent is to get the information out much quicker than the
formal publishing process allows.
• E-mail Orders
Send orders by e-mail including information from the IBM Redbooks fax order form to:
e-mail address
In United States or Canada pubscan@us.ibm.com
Outside North America Contact information is in the “How to Order” section at this site:
http://www.elink.ibmlink.ibm.com/pbl/pbl
• Telephone Orders
United States (toll free) 1-800-879-2755
Canada (toll free) 1-800-IBM-4YOU
Outside North America Country coordinator phone number is in the “How to Order”
section at this site:
http://www.elink.ibmlink.ibm.com/pbl/pbl
• Fax Orders
United States (toll free) 1-800-445-9269
Canada 1-403-267-4455
Outside North America Fax phone number is in the “How to Order” section at this site:
http://www.elink.ibmlink.ibm.com/pbl/pbl

This information was current at the time of publication, but is continually subject to change. The latest
information may be found at the Redbooks Web site.

IBM Intranet for Employees


IBM employees may register for information on workshops, residencies, and Redbooks by accessing
the IBM Intranet Web site at http://w3.itso.ibm.com/ and clicking the ITSO Mailing List button.
Look in the Materials repository for workshops, presentations, papers, and Web pages developed
and written by the ITSO technical professionals; click the Additional Materials button. Employees may
access MyNews at http://w3.ibm.com/ for redbook, residency, and workshop announcements.

© Copyright IBM Corp. 2001 217


IBM Redbooks fax order form

Please send me the following:


Title Order Number Quantity

First name Last name

Company

Address

City Postal code Country

Telephone number Telefax number VAT number

Invoice to customer number

Credit card number

Credit card expiration date Card issued to Signature

We accept American Express, Diners, Eurocard, Master Card, and Visa. Payment by credit card not
available in all countries. Signature mandatory for credit card payment.

218 Creating an Interactive B2B Web Application


Abbreviations and acronyms

ADS WebSphere Application


Development Solution
B2B business-to-business
CICS Customer Information
Control System
CCF Common Connector
Framework
CTG CICS Transaction
Gateway
ECI External Call Interface
EXCI External CICS Interface
HTML Hypertext Markup
Language
HTTP Hypertext Transfer
Protocol
IDE Integrated
Development
Environment
ITSO International Technical
Support Organization
IBM International Business
Machines Corporation
IMS Information
Management System
JAR Java archive
JSP Java Server Page
OTMA Open Transaction
Manager Access
TCP/IP Transmission Control
Protocol/Internet
Protocol
URL uniform resource
locator
USS Unix System Services
WAS WebSphere Application
Server

© Copyright IBM Corp. 2001 219


220 Creating an Interactive B2B Web Application
Index
running the order servlet 89
server processes 25
Numerics starting the MQSeries server applications 26
1414
system configuration document 40
MQSeries remote access port number 97 , 101,
ADSYSTEM
131, 133, 138
Host Name property 97, 101, 131, 133, 138
2059
ALLBIDS message type
reason code running accept or bid servlets 199
syntax 202
206
allbidsmsg.ccp
IN_LL property 166
input to record type 95
3336
IMS TCP/IP OTMA port number 162
500 B
jsp compilation error 200 BID message type
in servlet code 115
syntax 201
A bid servlet
A06C001
understanding session object code 193
applid of CICS demonstration region 27
bidmsg.ccp
CICS Server property value 53, 58, 66
input to record type 94
ABID message type 30
BOTHCONF message type 32, 126, 150, 154
syntax 202
syntax 205
ACCEPT message type 32, 125, 143
in servlet code 146
structure 127 C
syntax 203 CICS Connector 47
accept servlet CICS resource definitions 40
call from bid results page 188 CICS translation table 40
get bid data 196 CICS/ECI 6, 47, 60
get order data 195 CICSC001 27, 28, 32
using session objects 194 CICS demonstration region 25
acceptmsg.ccp CICSRPQ message queue 32
input to record type 128 CKBP
ACCEPTOK message type 126 MQ/CICS Bridge transaction 40
syntax 205 client
AcmeStuff 13, 179 required software 5
final page 190 COBOL
opening page 180 applications that access MQSeries 39
order page 182, 183 code page
shipping bids page 186 change for publishing on 390 82
ADS 4, 5, 12, 26 for IMS transaction 157, 159
CICS configuration 27 Common Connector Framework 51, 60, 73
customer application 34 connector jars 41
IBM WebSphere Application Development CPMI
Solution for OS/390 3 mirror transaction for V2CSTDB 54, 82
order applications 34 CTG 27, 47
running the accept servlet 153 CUSTOMER table 28, 33, 34, 47, 70
running the bid servlet 123 defining and populating 41

© Copyright IBM Corp. 2001 221


D bid messages 202
DB2 configuration 40
DBA1MSTR
DB2 process 25
I
IBM HTTP Server
demo files 21, 207 configuration on ADS 41
DFHMIRRS IMS Connector for Java 34, 155
clone of DFHMIR 40 add jar to Studio project 73
DFSMsg bean configuration 43
process IMS messages 160 IMS1ITOC
documentroot property 179 IMS connector process 25
IMWEBSRV
E WebSphere process 25
EBMR 83
mirror transaction for V2CSTDB 82
EBUS
J
Java Server Page 30
CICS group 40 add bid input fields 182
ERROR add shipping options selection 185
confirmation code from accept servlet 199 add to accept results 189
ERROR message type 32, 126, 150 invoke email bean 190
syntax 205 Javabeans Activation Framework 172
JAVADB database 12, 34, 36
G Javamail classes 172
GETORDRS 6, 12, 28, 47 javapgm.txt
input properties 59 input to record type 155, 158
input to record type 50 JAVATRAN 12, 34, 155
InteractionSpec ProgramName property 59 description 36
load module 40 IN_TRAN property 166
output properties 59 source file 206
retrieve order application 34, 57 JGATE01
source code 41 CICS Transaction Gateway process 25
source file 205
L
H local URL
Hub 125, 143, 197, 201 for publishing on 390 83
not running 199
HUBREPQ message queue 30, 100, 125, 126,
M
131, 133, 138, 143 mail server 172
accept messages 205 message queues
bid messages 202 CICSRPQ 32
reply queue for Hub 96 HUBREPQ 32
HUBREQQ message queue 29, 96, 99, 125, 128, HUBREQQ 29, 32
130, 131, 138, 143 HUBRESQ 30
accept messages 203 SxREQQ 30, 32
bid messages 201 message type
request queue for Hub 94 ABID 30
HUBRESQ message queue 30 ACCEPT 32
accept messages 205 ACCEPTOK 126

222 Creating an Interactive B2B Web Application


ALLBIDS 30 Shipper 1 process 25
BID 30 source file 205
BOTHCONF 32 MQSHIPR2
ERROR 32 Shipper2 process 25
REJECT 32 source file 205
MQ base classes 197 MQSHIPR3
MQ bindings connection 197 Shipper 3 process 26
MQ Client Attachment feature 39 source file 205
MQ Connector MQSHIPRx 29
add jar to Studio project 73
alternatives on OS/390 197
alternatives on S/390 199
O
order servlet
MQ/CICS Bridge 10, 32, 125, 126, 128, 142, 143,
understanding session object code 192
154
ORDERS table 28, 32, 34, 47, 70, 125, 126, 127,
configuration 39
142, 143, 154
MQA1 29
defining and populating 41
MQSeries Queue Manager on ADS 29
ORUPDATE 12, 32, 126, 143
MQSeries Queue Manager property 97, 131,
basis for ACCEPT message structure 127
133, 138
description 127
Queue Manager on ADS 39
in MQBBPLAN 39
MQA1CHIN
load module 40
MQSeries channel process 25
source code 41
MQA1MSTR
source file 206
MQSeries Queue Manager process 25
update order application 34
MQB2B
ORUPDATE message type
CICS group 40
syntax 204
MQBBPLAN
associate with ORUPDATE 39
DB2 plan 40 P
mqccf.jar permissions
MQConnector jar 122 provide for published files 88, 122, 152
MQConnector 29 publish
MQCP prepare for host 86
mirror transaction for GETORDRS and
ORUPDATE 59, 82
MQHUB 8, 12, 18, 25, 32
Q
queue definitions 39
description 36 Queue Manager
source file 205 default on ADS 39
MQHUBCPP 29 MQA1 36
hub process 25 on ADS 29
starting the hub application 26
MQHUBGO
hub job 26 R
MQMR 83 real world considerations
mirror transaction for GETORDRS 82 additional email data 34
MQSeries access port 39 CICS userid and password 27
MQSeries channel definition 39 connecting to MQSeries 30
MQSeries Integrator 30 connecting to remote queues 30
MQSHIPR1 remote applications 32

223
remote queues 39 features required for scenario 20
using MQSI 30 installing 19
REJECT message type 32, 126, 143
syntax 204
W
Web application
S developing your own 197
servlet configuration file how to start 26
acceptdate.servlet 150 provide interactive flow 179
custorder.servlet 84 URL to start the scenario 14
modify acceptdate.servlet 191 WebSphere
modify custorder.servlet 184 classpath 41, 42, 87, 122, 178
modify shipbids.servlet 189 configuration 41
shipbids.servlet 119 configuration file 41, 178
Servlet Engine configuration to run servlets 42
start in WebSphere Test Environment 78 define a web application 177
shipper applications 201 JSP level 179
description 35 WebSphere Application Server Version 3.5 197
not running 199 WebSphere Studio
processes 25 add resource files to project 73
providing ABID messages 30 customize project properties 72
starting the applications 26 installing 20
SHIPPERx set up local test stage 76
entry in Shipper field 199
shipping vendors 15
SHIPPER1, SHIPPER2, SHIPPER3 14
SHIPR1 25
SHIPR2 25
SHIPR3 26
SHIPRx 8, 12
SxREQQ message queues 32
accept messages 203
bid messages 201
SYSTEM.C001.BRIDGE.QUEUE
accept messages 204
SYSTEM.DEF.SVRCONN
MQSeries channel name 97, 101, 131, 133,
138

V
V2CSTDB 6, 12, 27, 28, 47, 48
command class to run 51
customer application 34
input properties 55
input to record type 49
InteractionSpec ProgramName property 54
output properties 56
source file 205
VisualAge for Java

224 Creating an Interactive B2B Web Application


IBM Redbooks review
Your feedback is valued by the Redbook authors. In particular we are interested in situations where a
Redbook "made the difference" in a task or problem you encountered. Using one of the following
methods, please review the Redbook, addressing value, subject matter, structure, depth and
quality as appropriate.
• Use the online Contact us review redbook form found at ibm.com/redbooks
• Fax this form to: USA International Access Code + 1 845 432 8264
• Send your comments in an Internet note to redbook@us.ibm.com

Document Number SG24-6221-00


Redbook Title Creating an Interactive B2B Web Application

Review

What other subjects would you


like to see IBM Redbooks
address?

Please rate your overall O Very Good O Good O Average O Poor


satisfaction:

Please identify yourself as O Customer O Business Partner O Solution Developer


belonging to one of the O IBM, Lotus or Tivoli Employee
following groups: O None of the above

Your email address:


The data you provide here may
be used to provide you with O Please do not use the information collected here for future
information from IBM or our marketing or promotional contacts or other communications beyond
business partners about our the scope of this transaction.
products, services or activities.

Questions about IBM’s privacy The following link explains how we protect your personal information.
policy? ibm.com/privacy/yourprivacy/

© Copyright IBM Corp. 2001 225


Creating an Interactive B2B Web Application

(0.5” spine)
0.475”<->0.875”
250 <-> 459 pages
®

Creating an Interactive
B2B Web Application

Access diverse This IBM Redbook will help you create an interactive Web
resources using application using IBM’s strategic e-development software,
INTERNATIONAL
connectors including VisualAge for Java, WebSphere Studio, and TECHNICAL
WebSphere Application Server. SUPPORT
Perform transactions ORGANIZATION
Using an S/390 server environment and a realistic scenario
across Business
involving business partners, you see how to access enterprise
Partners
resources in CICS, DB2, IMS, and MQSeries in a modern Web
application. BUILDING TECHNICAL
Exchange data INFORMATION BASED ON
among servlets PRACTICAL EXPERIENCE
Part 1 describes the overall scenario, including the
configuration of the server environment, an overview of the
steps you take to create the Web application, and how the IBM Redbooks are developed by
scenario pertains to real world business-to-business the IBM International Technical
scenarios. Support Organization. Experts
from IBM, Customers and
Partners from around the world
Part 2 walks you through detailed steps to create four servlets create timely technical
that provide the foundation for the Web application. You use information based on realistic
VisualAge for Java and WebSphere Studio to develop the scenarios. Specific
servlets. You deploy them to WebSphere Application Server recommendations are provided
to help you implement IT
on OS/390.
solutions more effectively in
your environment.
Part 3 tells how to join the servlets to form an interactive Web
application, involving three interactions with a user.

For more information:


ibm.com/redbooks

SG24-6221-00 ISBN 0738422029

You might also like