Tuesday, November 24, 2009

Full Kates Playground Sets

call a jsp ejb from Struts 1.x and Struts 2.x

java call an ejb from a servlet is extremely easy and is a
of the facilities that we provide the ejb version 3, but since it is a jsp
the same because you have to call by
JNDI (as is not complicated)

first let's create our ejb.


package ejb;
import
javax.ejb.Remote;


@ Remote public interface {saludoRemote

public String greet ();}




------------------------------------ package ejb;
import
javax.ejb.Stateless;

@ Stateless (name = "saludoRemote") public class
saludoBean implements

saludoRemote {public String greet () {return

hello from ejb "}



} so we have the draft

now go to our web project



only good from a servlet to call by
have the option of right click insert code-> call
enterprise bean and select our ejb and we generate the following code

@ EJB private
saludoRemote saludoBean;

saves the @ EJB jndi use, this call has
also be outside of any method of the servlet class.

another observation that I found on the web is different in the implementation
and JBoss glassfish server at the time of lookup
take on different servers.

eg for jboss

Context context = new InitialContext ();
HelloWorld helloWorld = (HelloWorld) Context.lookup ( "HelloWorldBean / remote" )

example: for glassfish

Context context = new InitialContext ();
HelloWorld helloWorld = (HelloWorld) Context.lookup ( HelloWorld.class.getName () )

0 comments:

Post a Comment