wood burning stoves
The moose likes JBoss/WildFly and the fly likes How to call ejb from jsp Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » JBoss/WildFly
Bookmark "How to call ejb from jsp" Watch "How to call ejb from jsp" New topic

How to call ejb from jsp

Anh Quang Le

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.");
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 " +
catch(Exception e) {
how must i write for jsp ?
Do I need config between Jboss and Tomcat ?
I agree. Here's the link: http://aspose.com/file-tools
subject: How to call ejb from jsp
It's not a secret anymore!