Stateless Bean based on Local Interface

05 Mar

package com.xavier.ejb3.sessionbean;

public interface HelloEJBLocal {

        public String hello(String name);


package com.xavier.ejb3.sessionbean;

import javax.ejb.Local;

import javax.ejb.Stateless;




public class HelloEJBBean implements HelloEJBLocal {

    public String hello(String name) {

return new String(“Hello “ + name);




<%@ page language=“java” contentType=“text/html; charset=UTF-8”


<%@ page


<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”>



<meta http-equiv=“Content-Type” content=“text/html; charset=UTF-8”>

<title>Hello EJB Local Bean</title>




try {

final Hashtable jndiProperties = new Hashtable();

jndiProperties.put(Context.PROVIDER_URL, “localhost:1099”);



Context ctx = new InitialContext(jndiProperties);

HelloEJBLocal hr = (HelloEJBLocal) ctx


out.println(“<br>Invoke EJB via Local Interface<br>”

+ hr.hello(“Xavier”));

} catch (Exception e) {

out.println(“<br>Invoke Local Interface failed.”);





Leave a comment

Posted by on 03/05/2012 in EJB


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: