| Author |
How to call ejb from jsp
|
Anh Quang Le
Greenhorn
Joined: Nov 30, 2003
Posts: 4
|
|
I can run ejb from Client Application, but i can run ejb from jsp, i have jboss3.0.4 and Tomcat -4.1.x, please help me This is Client Apllication Code : import javax.naming.*; import javax.rmi.PortableRemoteObject; import java.util.Properties; import com.javapro.ejb.StringProcessor; import com.javapro.ejb.StringProcessorHome; public class Client { public static void main(String[] args) { // first argument must be the input if (args.length==0) { System.out.println("Please specify the input to convert to upper case."); return; } String input = args[0]; // preparing properties for constructing an InitialContext object Properties properties = new Properties(); properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory"); properties.put(Context.PROVIDER_URL, "localhost:1099"); try { // Get an initial context InitialContext jndiContext = new InitialContext(properties); System.out.println("Got context"); // Get a reference to the Bean Object ref = jndiContext.lookup("StringProcessor"); System.out.println("Got reference"); // Get a reference from this to the Bean's Home interface StringProcessorHome home = (StringProcessorHome) PortableRemoteObject.narrow (ref, StringProcessorHome.class); // Create an Adder object from the Home interface StringProcessor sp = home.create(); System.out.println ("Uppercase of '" + input + "' is " + sp.toUpperCase(input)); } catch(Exception e) { System.out.println(e.toString()); } } } ---------------------------------------------------------------------- how must i write for jsp ? Do I need config between Jboss and Tomcat ?
|
 |
 |
|
|
subject: How to call ejb from jsp
|
|
|