有時客戶端程序(如JSP
先建立一個session bean本地接口
package service;
import java
import javax
@Local
public interface ShoppingCart
{
// 添加某個商品信息
public void addCommodity (String value);
// 獲得客戶購買的所有商品的紗銜泥
public List<String> getCommodity();
}
關於Session Bean的具體實現類與遠程接口的實現類一樣
下面在Eclipse中新建立一個Web工程(工程名
<%@ page language=
pageEncoding=
javax
<!DOCTYPE html PUBLIC
<html>
<head>
<meta http
<title>Insert title here</title>
</head>
<body>
</body> remote
<%
Properties prop = new Properties();
InitialContext ctx = new InitialContext();
ShoppingCart shoppingCart = (ShoppingCart) ctx
shoppingCart
shoppingCart
shoppingCart
List<String> commodities = shoppingCart
for(String commodity: commodities)
{
System
}
%>
</html>
訪問本地接口要使用的jndi name應為
啟動JBoss
在Eclipse的Console中會輸出如下的信息
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28645.html