// Copyright © 2002 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

shell> cat HelloWorldServlet.java

 
import java.io.*;
import java.text.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.naming.*;
import javax.rmi.*;


public class HelloWorldServlet extends HttpServlet {

    private HelloWorld hw = null;

    public HelloWorldServlet() throws NamingException
    {
        Context ctx = new InitialContext();
        HelloWorldHome home = (HelloWorldHome)
        	PortableRemoteObject.narrow(ctx.lookup("HelloWorld"),
            HelloWorldHome.class);
        try {
            this.hw = home.create();
        } catch (Exception e) { }
    }

    public void doGet(HttpServletRequest request,
                      HttpServletResponse response)
        throws IOException, ServletException
    {
        response.setContentType("text/html");
        PrintWriter out = response.getWriter();

        out.println("<html>");
        out.println("<head>");
        out.println("<title>Hola</title>");
        out.println("</head>");
        out.println("<body bgcolor=\"white\">");

        out.println("<h1> HelloWorldEJB Says: </h1>");
        out.println(this.hw.hi());

        out.println("</body>");
        out.println("</html>");
    }
}