Java Reference
In-Depth Information
Creating the client
In this section, we create a JSP test client to test the entity bean via the wrapper
session bean. First, create a JSP by selecting File | New . In the New Gallery window,
select Web Tier | JSP in Categories and JSP in Items . Click on OK :
In the Create JSP window, specify a File Name , EJB3Client.jsp , and click on OK . A
JSP gets added to the JSPViewController project. In JSP, create an InitialContext
object and lookup the session bean using the global JNDI name:
InitialContext context = new InitialContext();
CatalogSessionEJBRemote beanRemote = (CatalogSessionEJBRemote)
context.lookup("EJB3-SessionEJB#model.CatalogSessionEJBRemote");
The lookup() method returns an instance of the remote business interface. Create
some test data with the createTestData() method:
beanRemote.createTestData();
Next, list all the Catalog , Edition , Section , and Article entity instances.
For example, a List of all the Catalog entity instances is obtained with the
getAllCatalogs() method:
List<Catalog> catalogs=beanRemote.getAllCatalogs();
 
Search WWH ::




Custom Search