16.10.2015 Views

Getting Started with WebSphere Application Server

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5 – Enterprise Java Beans 105<br />

Step 2:<br />

Right click on ejb-studentweb -> New -> Servlet to create a Servlet named<br />

StudentCreditCalculator. Paste the code from the accompanying zip file <strong>with</strong><br />

exercises for this book. The code snippet is shown in Listing 5.16<br />

package com.ibm.start.wasce.studentweb;<br />

public class StudentCreditCalculator extends HttpServlet {<br />

……<br />

@EJB<br />

private StudentEJBInterface studentejb;<br />

protected void doGet(HttpServletRequest request,<br />

HttpServletResponse response)<br />

throws ServletException, IOException{<br />

List creditList = studentejb.calculateCredit();<br />

for (int i=0;i Build Path -> Configure Build Path -> Projects, add ejbstudentejb<br />

project on build path<br />

Step 4:<br />

Right click ejb-studentweb -> Properties -> Project Reference, click ejb-studentejb as a<br />

reference.<br />

8. Create an Enterprise <strong>Application</strong> Project<br />

Step 1:<br />

In Eclipse click on File -> New ->Other…-> Enterprise <strong>Application</strong> Project to create a<br />

enterprise application project ejb-studentear. In the creating wizard, fill in the second<br />

dialog as shown in Figure 5.7, then click Finish.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!