web项目调用Ejb3.0组件学习

本文详细介绍了如何在web项目中调用Ejb3.0组件,包括创建Ejb3.0项目,编写业务接口和无状态会话bean,创建web项目并实现servlet,配置web.xml,以及打包和发布步骤。通过实例展示了ejb3.0在web应用中的使用。
摘要由CSDN通过智能技术生成

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><

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值