web项目调用Ejb3.0组件
采用的开发工具为
JbossIDE+MyEclipse+JBoss4.04
一,首先建立一个ejb3.0项目EJB1+WEB
业务接口:
import javax.ejb.Remote;
@Remote
public interface Caculator {
public int add(int x,int y);
public int substact(int x,int y);
}
一个无状态会话bean:
import javax.ejb.Stateless;
import cn.com.liang.Caculator;
public @Stateless class CaculatorBean implements Caculator {
public int add(int x, int y) {
return x+y;
}
public int substact(int x, int y) {
return x-y;
}
}
打包测试成功calculator.jar
二:新建一个web项目EjbWeb
建一个index.jsp页面
<body>
<form name="f1" action="servlet/CaculatorServlet" method="post">
<table>
<tr>
<td>number1:<input type="text" name="n1"/></td>
</tr>
<tr>
<td>number2:<input type="text" name="n2"/></td><