How do I initiate a JNDI lookup from an applet?

Luigi Viggiano

First, in the jar file of your applet you will need followin classes included:

  1. Classes from the jar with the client portion of your specific jndi provider classes
  2. Classes from the the jar containing javax.naming standard extensions.
  3. Classes from the jar containing javax.rmi.PortableRemoteObject (only if the retrieved object are CORBA objecs)
  4. The classes you want to lookup.
Then, the host where the lookup has to be done must be the same from wich your applet has been downloaded (otherwise the applet must be signed).
The client browser must be able to open a connection to the port of where the naming service is listening (be sure about proxy settings etc.).
The client browser must have Java 2 (Java Plugin 1.2.x)
Then the code is always the same:

Properties props = new Properties();
props.setProperty("java.naming.factory.initial",
                  "org.jnp.interfaces.NamingContextFactory" );
props.setProperty("java.naming.provider.url", "codebaseurl:1099");
Context ctx = new InitialContext(props);
Object ref = ctx.lookup("jndi_name");
Note: it's generally avoided to use applet working on remote object, for such many difficulties and for applet security limitations, so it's better to think about applet asking services to server object thru servlets.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact