《J2EE企业级应用开发》一书的配套源代码
源代码在线查看: order.jsp
javax.servlet.http.*,java.rmi.*,javax.rmi.PortableRemoteObject,javax.ejb.*,com.j2eeapp.cdstore.order.*,com.j2eeapp.cdstore.vo.*" %>
InitialContext ctx=new InitialContext();
try
{
OrderLocalHome orderHome = (OrderLocalHome)ctx.lookup("ejb/order/order");
OrderLocal order;
OrderStatusLocalHome osh=(OrderStatusLocalHome)ctx.lookup("ejb/order/orderstatus");
//OrderStatusLocal osl=osh.create(new OrderStatus("order_demo_159","order_demo_159",OrderStatusLocalHome.ORDER_STATUS_NOTCOMFIRMED));
OrderStatusLocal osl=osh.findByPrimaryKey("order_demo_159");
/** for(int i=10;i {
order=orderHome.create("order_demo_"+i);
}**/
order= orderHome.findByPrimaryKey("order_demo_11");
order.setUserId("hellking_111");
order.setOrderDate(System.currentTimeMillis());
order.setTotalPrice(12.3f);
order.setCreditCard(new CreditCard("hNo.248274-324-324","dskfj",new java.util.Date()));
order.setOrderStatus(osl);
/** LineItemLocalHome lineItemHome = (LineItemLocalHome)ctx.lookup("ejb/order/lineitem");
LineItemLocal lineItem=null;
lineItem= lineItemHome.findByPrimaryKey("item8475"); */
/** order.addLineItem(new LineItem("lineitem105","item8479",2,566.5f));
order.addLineItem(new LineItem("lineitem101","item8477",3,45.55f));
order.addLineItem(new LineItem("lineitem102","item8478",3,45.55f));**/
out.println("orderid#");
out.println(order.getOrderId());
out.println("userid$");
out.println(order.getUserId());
out.println("cardnumber$");
out.println(order.getCreditCard().getCardNumber());
out.println("orderstatus.status=");
out.println(order.getOrderStatus().getStatus());
out.println("");
Collection c=order.getAllItems();
Iterator it=c.iterator();
while(it.hasNext())
{
LineItem li=(LineItem )it.next();
out.println("itemid");
out.println(li.getItemId());
out.println("lineitem.quantity");
out.println(li.getQuantity());
}
}
catch(NamingException e)
{
e.printStackTrace();
}
%>