FileDocCategorySizeDatePackage
EJBServlet.javaAPI DocExample1047Sat May 31 17:18:38 BST 2003None

EJBServlet

public class EJBServlet extends HttpServlet

Fields Summary
protected Hello
hello
Constructors Summary
Methods Summary
public voiddoGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)


		PrintWriter out = response.getWriter();
		response.setContentType("text/html");

		out.println("<html><head><title>Hello</title></head>");
		out.println("<body>");
		out.println("<p>There is an EJB here and it says...");

		out.println("<b>" + hello.hello() + "</b>");
		out.println("</p>");
		out.println("</body></html>");
	
public voidinit()


		try {
			Context initial = new InitialContext();

			Object objref = initial.lookup("Hello");

			HelloHome home =
				(HelloHome)PortableRemoteObject.narrow(objref, HelloHome.class);

			hello = home.create();

		} catch (Exception exc) {
			log(exc.toString());
			throw new ServletException(exc.getMessage());
		}