JNDI code for looking up a Session EJB should not be in the
Java servlet.
Check out the Business Delegate design
pattern for the Java EE way of handling this communication.
Servlet should call coarse-grained business method of Business Delegate.
Business Delegate then, optionally uses Service Locator, connects to Session EJB and calls business method.
In the code of the Session EJB, then the Entity EJB is created and processed.
When the Session EJB is done processing, it either returns nothing, throws an Exception to the Business Delegate, or returns a data object to the Business Delegate.
The Business Delegate then returns the data object to the servlet.
JNDI lookup code goes in Business Delegate to locate Session EJB.
JNDI lookup code goes in Service Locator to locate Entity EJB.
[ September 12, 2008: Message edited by: James Clark ]