Home > Articles > Programming > Java

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Step 6: Packaging the JSP As a Web Component

We've just completed the packaging of the EJB component. Now, let's package the Web components, consisting of JSP pages, into the CMP20WAR file.

  1. First, package the JSP clients for AddressEJB. In the deployment tool, select the File|New|Web component, which brings up a Web Component Wizard. Click Next. In the Wizard, select the Create New WAR File in Application button to display CMP20App. In the WAR Display Name area, enter CMP20WAR and then click Edit. The Edit Content window will pop up. Go to the APPHOME\chapter11\web directory, and add index.html and createStudent.jsp to the WAR file (see Figure 11-18). Click OK, and then click Next.

    Figure 11-18Figure 11-18 Creating a createStudent.jsp for CMP20WAR

  2. Next, select the JSP radio button to indicate the type of Web component, and select Next from the pull-down menu. Select createStudent.jsp as the JSP Filename; take all the default values (see Figure 11-19). Click Next twice.

    Figure 11-19Figure 11-19 Specifying the createStudent.jsp type for the Web component

  3. Now, specify the component alias name. Click Add and enter createStudent.jsp as shown in Figure 11-20. Click Next four times.

    Figure 11-20Figure 11-20 Specifying the JSP alias name

  4. Because the createStudent.jsp client references StudentEJB, specify EJB references. Click Add and then enter ejb/StudentRef as the Coded Name. Use the pull-down menu to select Entity as the Type and local as the Interface. Enter LocalStudentHome and LocalStudent as the Home and Local/Remote Interfaces using the full path name (for example, j2eebootcamp.developingEJB.chapter11.cmp). Then, as the Enterprise Bean Name, enter StudentEJB (see Figure 11-21). Click Finish.

    Figure 11-21Figure 11-21 Specifying EJB references to StudentEJB

  5. Now, create the searchStudent component. Select the File|New|Web component, and click Next. To package all the JSP files into one war file, select Add to Existing WAR File and use the pull-down menu to select CMP20WAR. Click Edit.

  6. In the Edit Content window, go to the APPHOME\chapter11\cmp directory and add searchStudent.jsp (see Figure 11-22). Click OK; then Next, then JSP and Next again. Under JSP Filename, select searchStudent.jsp. Accept the default values (see Figure 11-19—note that the name should say searchStudent). Click Next twice; click Add and enter searchStudent.jsp (see Figure 11-20—note that the name should say searchStudent.jsp). Click Next four times. In the EJB reference window, enter ejb/StudentRef, Entity, Local, LocalStudentHome, and LocalStudent (see Figure 11-21). Click Finish.

    Figure 11-22Figure 11-22 Adding the JSP Component to Existing WAR File Ð CMP20WAR

  7. The steps necessary to package createAddress.jsp is the same as the steps we used to package searchStudent.jsp. To package the createAdddress.jsp file, follow the sequence of steps we outlined for packaging the searchStudent.jsp file. Now add createAddress.jsp (see Figure 11-18) to the CMP20WAR file; specify it as a JSP component, and specify the JSP filename (see Figure 11-19). Use createAddress.jsp as the alias (see Figure 11-20). Then, use ejb/AddressRef, entity, local, LocalAddressHome, LocalAddress, and AddressHome in the EJB reference (see Figure 11-21) and click Finish.

  8. Repeat the same sequence of steps to package searchAddress.jsp, except in this case, replace createAddress.jsp with searchAddress.jsp and use the EJB references (ejb/AddressRef, entity, local, LocalAddressHome, LocalAddress, and AdddressEJB) as in the previous steps. Click Finish.

  9. Repeat the same series of steps to package createRoster and searchRoster. Replace the searchAddress.jsp with searchRoster.jsp and specify ejb/RosterRef, entity, local, LocalRosterHome, LocalRoster, and RosterEJB in the EJB reference window. Repeat the steps for searchRoster.jsp.

  10. After you package both the EJB and JSP components, all six JSP components should be included under the CMP20WAR icon, and three entity beans should be included under the CMP20JAR icon. Select the CMP20App icon 10. and then select the JNDI Name tab. Enter MyStudent, MyAddress, and MyRoster under the JNDI Name column (see Figure 11-23).

    Figure 11-23Figure 11-23 Completing the packaging of the sample application

  • + Share This
  • 🔖 Save To Your Account