Now you will run two page flow applications to test the EJBs. Both page flows allow you to add a band to a database and to view the list of bands. The two applications differ only in how they reference the Music EJB. The first page flow uses EJB Controls in the page flow controller file. The second page flow uses JNDI naming defined directly in the JSP. You can either run both page flow applications or skip the second one.
Note. Page flows and EJB controls are not the main topics of this tutorial and are used here primarily to demonstrate how to run EJBs. To learn more about page flows and EJB controls, see the related topics at the bottom of this page.
Before you run this page flow, you first might want to examine the structure of this web application.
To Examine the EJB Control
Note. If the definition of the EJB control reports errors, please go back to the previous step of the tutorial and make sure that the mentioned names are set correctly in the Property Editor. If you make corrections to the Music bean, you must rebuild the EJB project.
To Examine the Page Flow
/** * @common:control */ private EJBControls.MusicBeanControl library;
protected Forward addABand(AddABandForm form) { ... library.addBand(info); allBands = library.getBands(); ... }
To Run the Page Flow
This page flow is solely intended to demonstrate how EJBs can be called directly from a JSP and without using an EJB control. In general it is recommended that you use an EJB control called from a page flow controller file instead, as shown in the above page flow application.
Before you run this page flow, you first might want to examine the structure of this web application.
To Examine the web.xml Descriptor
<ejb-local-ref>
<ejb-ref-name>ejb/MusicLink</ejb-ref-name>
<ejb-ref-type>Session</ejb-ref-type>
<local-home>examples.ejb20.relationships.bands.MusicHome</local-home>
<local>examples.ejb20.relationships.bands.Music</local>
<ejb-link>MyEJBProject.jar#Music</ejb-link>
</ejb-local-ref>
Note. If the definition of the <ejb-local-ref> element does not match the Music bean's interfaces, please go back to the previous step of the tutorial and make sure that the mentioned names are set correctly in the Property Editor. If the name of the JAR file (in the ejb-link descriptor) is incorrect, rename the EJB project as specified in step 1 of the tutorial. After you make corrections, you must rebuild the EJB project.
To Examine the JSP page
To Run the Page Flow
Getting Started: Java Controls
Getting Started: Web Applications
Click one of the following arrows to navigate through the tutorial: