Professional Documents
Culture Documents
Creating An Interactive b2b Web Application
Creating An Interactive b2b Web Application
Deborah Cottingham
Denis Gaebler
ibm.com/redbooks
SG24-6221-00
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.
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.
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.
Figures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .ix
Tables. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xiii
Preface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Audience . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
The team that wrote this redbook . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xv
Comments welcome . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xvii
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
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
vii
Abbreviations and acronyms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 219
Index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 221
xi
xii Creating an Interactive B2B Web Application
Tables
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 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.
We would like to thank the following people for their technical contributions to
this project:
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.
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.
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.
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.
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.
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.
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.
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.
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.
Chapter 1. Introduction 7
Figure 3. Bid servlet input page
Chapter 1. Introduction 9
Figure 5. Accept servlet input page
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.
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.
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.
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.
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
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.
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.
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!
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.
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.
VisualAge for Java may add some other features that it requires to work with
these features.
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.
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.
JAVADB
IMS Transaction Manager
AcmeStuff.html
MQHUB
WebSphere C ++ Application
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
HUBRESQ
CUSTOMERS ORDERS
Jobname Purpose
JGATE01 CICS Transaction Gateway, which receives CICS requests from the
servlet, passes them to the CICS region, and returns the reply to
the servlet.
The Web server downloads the AcmeStuff.html page to the Web browser,
which displays it for the user, as shown in Figure 14.
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
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.
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.
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
To access the ADS default queue manager from another system, access port
1414, on which the queue manager is listening.
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 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.
Feature Jar
MQ Connector /demos/jars/mqccf.jar
To learn how to use the IMS Connector for Java, see the online help in
VisualAge for Java.
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.
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.
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.
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
3. Click Next.
4. Specify the properties shown in Table 5 for the record attributes.
Table 5. CustomerRecord record attributes
Property Value
The entries for the B2BApp should look similar to this for your workspace.
However, your names will follow your own naming convention.
Property Value
5. Click Finish.
8. Click Next.
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.
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.
CUSTNO outputCUSTNO
STATE outputSTATE
ADDRESS1 outputADDRESS1
COUNTRY outputCOUNTRY
CITY outputCITY
FIRSTNAME outputFIRSTNAME
LASTNAME outputLASTNAME
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.
Property Value
CCUSTNO outputCCUSTNO
CITEM outputCITEM
CITEMNO outputCITEMNO
CITEMCST outputCITEMCST
CSHPDATE outputCSHPDATE
CSHPPER outputCSHPPER
CSHPCOST outputCSHPCOST
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.
You have completed creating the beans that access CICS and DB2.
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
Figure 33. Order package, containing all the beans and a test application
The Console window opens with the result that should look similar Figure 34.
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.
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.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.
File Location
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
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
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.
You set up the Servlet Engine classpath, start the Servlet Engine, and then
open your input html page in a Web browser.
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.
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.
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.
<?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>
custorderHTMLInput.html /demos/b2bapp/html
custorderHTML*.jsp /demos/b2bapp/html
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.
The input screen for the servlet displays, similar to Figure 40.
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.
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.
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.
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.
3. Click Next.
4. Specify the properties listed in Table 23 for the Record Attributes Bean.
Table 23. BidRequest record attributes
Property Value
5.Click Finish.
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.
3. Click Next.
4. Specify the properties listed in Table 25 for the Record Attributes Bean.
Table 25. AllBidsReply record attributes
Property Value
5. Click Finish.
Property Value
MQSeries Queue Manager Name MQA1, which is the queue manager defined on
the ADS
Property Value
Format STRING
To customize the input bean, you specify which fields you want to put on the
HUBREQQ queue.
Item Selection
Project B2BApp
Package bid
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 Queue Manager Name MQA1, which is the queue manager defined on
the ADS
Property Value
Message Type 8
To create the output bean, you specify the fields that you want to receive from
HUBREPQ.
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
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
Property Value
Figure 48. BidsNavigator, in the Visual Composition Editor in VisualAge for Java
Figure 49. The bid package, containing all beans and the navigator
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
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.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.
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
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
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.
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
Now you know the bid servlet executes properly and you are ready to publish
it to the host.
shipbidsHTMLInput.html /demos/b2bapp/html
shipbidsHTML*.jsp /demos/b2bapp/html
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.
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.
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.
3. Click Next.
4. Specify the properties listed in Table 38.
Table 38. AcceptRequestmessage record attributes
Property Value
5. Click Finish.
3. Click Next.
4. Specify the properties listed in Table 40.
Table 40. AcceptRequestmessage record attributes
Property Value
5. Click Finish.
Property Value
MQSeries Queue Manager Name MQA1, which is the queue manager defined on
the ADS
Property Value
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.
Property Value
Property Value
Message Type 8
Format STRING
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
Property Value
Figure 61. The accept package, containing all the beans and the navigator
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.
The Console window opens with the result, similar to Figure 63.
If you did not see the correct result or the debugger window opened, see
Chapter 9, “Troubleshooting” on page 199.
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.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.
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.
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
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.
customerNumber 3
orderItemNumber 4156
orderShipper SHIPPER3
orderShipDate 10/31/2000
orderShipCost .20
You are finished with WebSphere Test Environment for now, so you can stop
it.
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.*
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.
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.
In the next step you create the Transaction Input Record Bean.
After some processing the Create Record from Record Type SmartGuide
Window opens. The next step is to create the Transaction Output Record
Bean.
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
The DFSMsg bean is used to process messages from IMS other than the
output of the transaction, such as error or status messages.
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.
Tip: The command editor is also accessible through Tools -> Enterprise
Access Builder -> Edit Command.
import javax.mail.*;
import javax.mail.internet.*;
6. Then add the code in Figure 83 to the servlet after executing the
EABExecutecmd command bean (which retrieved the email address from
IMS):
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.
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
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
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.
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
########################################################
Scroll down the Web page to find the title. This book refers to the
configuration file as was.conf.
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.
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
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
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
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.
Because you have a new file for the results page, AcmeStuffOrder.jsp, you
need to update the order servlet configuration file.
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.
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.
<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>
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.
Because we have a new file for the results page, AcmeStuffBids.jsp, we need
to update the bid servlet configuration file.
...<default-page>
<uri>/demos/b2bapp/html/AcmeStuffBids.jsp</uri>
</default page> ...
Figure 97. Page produced from modified accept servlet results 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.
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 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));
We will use the allbids object later in the accept servlet. You do not need to
make any changes to the bid servlet.
Since we need to also access the order navigator and the bids navigator, add
the following import statements:
import order.CICSRetrieveNavigator;
import bid.BidsNavigator;
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);
Load the accept navigator customerNumber property from the order bean’s
customerNumber property.
accnav.setCustomerNumber(acustorder.getCustomerNumber());
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.
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.
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
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.
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
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
MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item
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
MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item
MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item
MM/DD/YYYY 10 Closest date to desired date that shipper can deliver item
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
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
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
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
This redbook contains additional material on the Web. This section tells how
to acquire and use the material.
ftp://www.redbooks.ibm.com/redbooks/SG246221
ibm.com/redbooks
Select the Additional materials and open the directory that corresponds with
the redbook form number.
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.
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
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.
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.
SET, SET Secure Electronic Transaction, and the SET Logo are trademarks
owned by SET Secure Electronic Transaction LLC.
The following publications and Internet addresses may be useful if you decide
to implement your own application.
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.
Company
Address
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.
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
Review
Questions about IBM’s privacy The following link explains how we protect your personal information.
policy? ibm.com/privacy/yourprivacy/
(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.