O'Reilly logo

MySQL™ and JSP™ Web Applications: Data-Driven Programming Using Tomcat and MySQL by James Turner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating a Stateless Session Bean

Now you can move on to actually creating your first EJB. To begin, create a new subdirectory called ejb in your com/bfg source hierarchy. You're going to move the logic that computes sales tax into a bean called Cart. Start by writing the remote interface (see Listing 17.1), which extends EJBObject. There's not much to it really—it just declares the calling parameters for the computeTax call and specifies that it throws RemoteException, as all EJB beans must.

By convention, if a bean implements a functionality called Foo, the remote interface is called Foo, the home interface is called FooHome, and the enterprise bean is called FooBean.

Listing 17.1. Cart.java
 package com.bfg.ejb.cart; import javax.ejb.EJBObject; ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required