tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Carlos Ferrão <cfer...@criticalsoftware.com>
Subject InitialContext in JSP files to access EJBs in JBoss
Date Tue, 10 Jul 2001 04:23:03 GMT


	Hello All,

	Whenever I need to use a stateless session bean I have to put the following
in my JSP:

     javax.naming.Context mycontext = new javax.naming.InitialContext();
     java.lang.Object library_ref = mycontext.lookup("acc_library");
     accessprj.acc_libraryHome libraryhome = (accessprj.acc_libraryHome)
javax.rmi.PortableRemoteObject.narrow(library_ref,accessprj.acc_libraryHome.
class);
     accessprj.acc_library library =libraryhome.create();

I made a Class to set the properties as follows:

public class ContextPropertiesFactory {
  public Properties getInitialContextPropertiesFactory() {
    Properties prop = new Properties();

prop.setProperty(Context.INITIAL_CONTEXT_FACTORY,"org.jnp.interfaces.NamingC
ontextFactory");
    prop.setProperty(Context.PROVIDER_URL,"localhost:1099");
    return prop;
  }
  public void makePropertiesDefault() {
    System.setProperties(getInitialContextPropertiesFactory());
  }
}

Now I call the getInitialContextPropertiesFactory() method and initialize my
context with the Properties that are returned from the method so I can use
JBoss.

Do I have to do something like this in every JSP page I have??

	Thanks in advance,
	Carlos Ferrao


Mime
View raw message