/* * * Copyright 1999, 2000 Sun Microsystems, Inc. All Rights Reserved. * * This software is the proprietary information of Sun Microsystems, Inc. * Use is subject to license terms. * */ import javax.rmi.PortableRemoteObject; import javax.naming.*; import javax.servlet.jsp.*; import javax.servlet.jsp.tagext.*; public class EjbTag extends BodyTagSupport { private String jndiName = null; private String homeVar = null; private String homeInterface = null; public EjbTag() { super(); System.out.println("EjbTag()"); } public void setJndiName(String jndiName) { System.out.println("setJndiName()"); this.jndiName = jndiName; } public void setHomeVar(String homeVar) { System.out.println("setHomeVar()"); this.homeVar = homeVar; } public void setHomeInterface(String homeInterface) { System.out.println("setHomeInterface()"); this.homeInterface = homeInterface; } public void doInitBody() throws JspException { try { System.out.println("doInitBody()"); InitialContext ic = new InitialContext(); Object homeRef = ic.lookup(jndiName); homeRef = PortableRemoteObject.narrow(homeRef, Class.forName(homeInterface)); pageContext.setAttribute(homeVar, homeRef); } catch (NamingException ex) { throw new JspTagException("Unable to lookup home: "+jndiName); } catch (ClassNotFoundException ex) { throw new JspTagException("Class "+homeInterface+" not found"); } } }