|  |  |  | 
 Configuring an EJB client using the Burlap protocol uses the
        BurlapContextFactory as a JNDI link.  The client will use
        JNDI to lookup the EJB home interfaces. 
   
   
  Resin-EJB with Burlap
  
  | 
<web-app>
  <jndi-link>
    <jndi-name>java:comp/env/ejb</jndi-name>
    <jndi-factory>com.caucho.burlap.BurlapContextFactory</jndi-factory>
    <init-param java.naming.provider.url="http://host.com/burlap"/>
  </jndi-link>
</web-app>
 |  Sample client code follows.  The EJBHome lookup is in the init()
method for efficiency. 
   
  Client Servlet
  
  | 
import javax.servlet.*;
import javax.namingdservlet.*;
public class ClientServlet extends GenericServlet {
  TestHome home;
  public void init()
    throws ServletException
  {
    try {
      Context env = (Context) new InitialContext().lookup("java:comp/env");
      home = (TestHome) env.lookup("ejb/test");
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
  public void service(ServletRequest req, ServletResponse res)
    throws IOException ServletException
  {
    try {
      PrintWriter out = res.getWriter();
      Test test = home.findByPrimaryKey("test");
      out.println("test:" + test.hello());
    } catch (Exception e) {
      throw new ServletException(e);
    }
  }
}
 |  
 
  | Copyright © 1998-2005 Caucho Technology, Inc. All rights reserved. Resin® is a registered trademark,
and HardCoretm and Quercustm are trademarks of Caucho Technology, Inc.
 |  |  |