<document>
  <header>
    <product>resin</product>
    <title>Burlap EJB Client</title>
    <description>
      <p>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.</p>
    </description>
  </header>

  <body>
    <summary/>

<section title="Burlap EJB Client">

<example title="Resin-EJB with Burlap">
&lt;web-app>
  &lt;jndi-link>
    &lt;jndi-name>java:comp/env/ejb&lt;/jndi-name>
    &lt;jndi-factory>com.caucho.burlap.BurlapContextFactory&lt;/jndi-factory>
    &lt;init-param java.naming.provider.url="http://host.com/burlap"/>
  &lt;/jndi-link>
&lt;/web-app>
</example>

<p>Sample client code follows.  The EJBHome lookup is in the <code/init()/>
method for efficiency.</p>

<example title="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);
    }
  }
}
</example>

</section>

  </body>
</document>
