514 IBM WebSphere Host Publisher Version 3.5
5. Scenario 5: Accessing Host Publisher EJB from user EJBs.
6. Scenario 6: Accessing Host Publisher EJB from user EJBs with chaining.
7. Scenario 7: Changing Host Publisher EJB from EJB session stateful to
stateless.
Note: EJB support is provided for database and host Integration Objects; in
these scenarios, we are only using host Integration Objects.
17.4.1 Scenario 1: Accessing Host Publisher EJB from local JSPs
This scenario illustrates and guides you through the process of implementing a
simple Host Publisher application using Host Publisher EJB support and JSPs
created to instantiate the EJB Access Bean in order to locally access the Host
Publisher EJB. The scenario is shown in Figure 17-8.
Note: The procedure to access Host Publisher EJB from local servlets is very
similar, but will not be shown in this scenario.
Figure 17-8 Accessing Host Publisher EJB from a local JavaServer Page (JSP)
In this scenario, the request flow goes las follows (see Figure 17-8):
1. The JSP is accessed from the Web browser, for example via URL or a POST
operation. The JSP instantiates the EJB Access Bean (a JavaBean). The EJB
Access Bean was previously generated by Host Access (Studio) when you
saved the Integration Object. Also, the interface that the EJB Access Bean
provides is similar to the one provided by the Integration Object (setters,
doHPTransaction and getters methods).
2. When the execution method is invoked in the EJB Access Bean, it
communicates with the Host Publisher EJB (a session stateful EJB) via
RMI/IIOP. That is, the EJB Access Bean provides the EJB client code and it
will use the provided JNDI by default to locate the Host Publisher EJB.
Chapter 17. EJB application support 515
Note: Since the communication between the EJB Access Bean and the Host
Publisher EJB is local in this scenario, the TCP/IP stack is not used and
therefore provides better performance.
3. The Host Publisher EJB instantiates the Integration Object (a JavaBean)
using the setters, doHPTransaction and getters methods.
4. The Integration Object executes the host application transaction via the Telnet
3270 (or 5250) transport and passes the response back to the Host Publisher
EJB.
For this scenario, we assume that the Integration Object has already been
created and EJB support files have been generated using the procedure
described in 17.3, Adding EJB support to Integration Objects on page 509.
Sample JSP
You can create JSPs to instantiate, drive and render the EJB Access Bean output
properties in the same way that the original Integration Objects are used. The
difference is in using the proper Java Bean name. For example, the EJB Access
Bean will have a name of the form <IOName>Access0.jar for an Integration
Object with name <IOname>.
In this scenario, the Integration Object name is Hobj01.jar and therefore its
associated EJB Access Bean name will be Hobj01Access0.jar, where Access0 is
the default suffix. However, you can change the suffix value if required when
creating your Integration Object and EJB support files.
The sample JSP to invoke the EJB Access Bean is shown in Figure 17-9 on
page 516.
516 IBM WebSphere Host Publisher Version 3.5
Figure 17-9 Sample JSP used to invoke the EJB Access Bean
The sample JSP was created using the Host Publisher Studio (see Chapter 10,
Creating applications on page 301). However, the JSP can be created using
other tools and editors, for example, WebSphere Studio (see Chapter 15,
Integration Objects and WebSphere Studio on page 405).
Transferring and deploying applications using EJB Access
In this section, we show you how to transfer and deploy your application using
JSPs in a local environment.
Step 1: Transfer and deploy the application
Transfer and deployment of Host Publisher applications that are created using
EJB Access Beans are the same as transfer and deployment of Host Publisher
applications using the Integration Object directly.
<HTML>
<%@ page contentType="text/html;charset=ISO-8859-1" %>
<TITLE> EJBSample1Output</TITLE>
BODY>
<H1> EJBSample2 Result page</H1>
<br>
<jsp:useBean id="Hobj01Access0" type="IntegrationObject.Hobj01Access0"
class="IntegrationObject.Hobj01Access0" scope="request">
<jsp:setProperty name="Hobj01Access0" property="*" />
</jsp:useBean>
<% Hobj01Access0.setHPubErrorPage("EJBSample1Error.jsp"); %>
<% Hobj01Access0.setHPubStartPoolName("hpool01"); %>
<% Hobj01Access0.doHPTransaction(request, response); %>
<%
if (Hobj01Access0.getHPubErrorOccurred() != 0) {
// Error page redirection already done by IO
return;
}
%>
<P>Account: <%= Hobj01Access0.getAccountOut() %>
<P>Surname: <%= Hobj01Access0.getSurnameOut() %>
<P>Firstname: <%= Hobj01Access0.getFirstnameOut() %>
<P>Address: <%= Hobj01Access0.getAddressOut() %>
</BODY>
</HTML>

Get A Comprehensive Guide to IBM WebSphere Host Publisher Version 3.5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.