⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 customer.jsp

📁 《J2EE企业级应用开发》一书的配套源代码
💻 JSP
字号:
<%@ page import="java.io.IOException,java.util.*,javax.naming.*,javax.servlet.*,
javax.servlet.http.*,java.rmi.*,javax.rmi.PortableRemoteObject,javax.ejb.*,com.j2eeapp.cdstore.customer.*,
com.j2eeapp.cdstore.vo.*" %>
<%
	InitialContext ctx=new InitialContext();
   
   try
   {
   	
    
   CustomerLocalHome customerHome = (CustomerLocalHome)ctx.lookup("ejb/customer/customer");
   CustomerLocal customer;
	//customer=customerHome.create("customer_demo_4");
	customer= customerHome.findByPrimaryKey("sdf"); 
	if(customer!=null)
	out.println("customer is not null");
	out.println("<br>");
	
	AccountLocal account=customer.getAccount();
	if(account!=null)out.println(account.getStatus());
	else out.println("account is null");
	out.println("<br><hr>");
	AccountLocalHome accountHome=(AccountLocalHome)ctx.lookup("ejb/customer/account");
	account=accountHome.findByPrimaryKey("sdf");
	
	ProfileLocal profile =customer.getProfile();
	if(profile!=null)out.println("profile.userid"+profile.getUserId());
	else out.println("profile is null");
	//ProfileLocalHome profileHome=(ProfileLocalHome)ctx.lookup("ejb/customer/profile");
	 //profile=profileHome.create("sdsdfdsfdsff","kkkkkkkk",true);
	// profile=profileHome.findByPrimaryKey("sdsdfdsfdsff");
	 
	 
	    out.println("<br><hr>");
		CreditCardLocalHome creditHome=(CreditCardLocalHome)ctx.lookup("ejb/customer/creditcard");
	  	// CreditCardLocal credit=creditHome.create("cardNo90","hhh",new java.util.Date());
	  	CreditCardLocal credit=creditHome.findByPrimaryKey("cardNo90");
	  	 if(credit!=null)out.println("credit is not null&number="+credit.getCardNumber());
	  	 else out.println("credit is null");
	  	 out.println("<br><hr>");
	   ContactInfoLocalHome contactHome=(ContactInfoLocalHome)ctx.lookup("ejb/customer/contact");
	  // ContactInfoLocal contact=contactHome.create(new ContactInfo("hk","df","sdkjf",new Address("street","city","state","zip")));  	 
	 
	  ContactInfoLocal contact=contactHome.findByPrimaryKey("hk");
	  if(contact!=null)out.println("contact.name="+contact.getName());
	  else out.println("contact is null");
	 out.println("<br><hr>");
	 
		account.setContactInfo(contact);
        account.setCreditCard(credit);
       		  customer.setAccount(account);
	 customer.setProfile(profile);
	 ProfileLocal profile2=customer.getProfile();
	 if(profile2!=null)out.println("profile.userid="+profile2.getUserId());
	 else out.println("profile2 is null");
	 	out.println("<br><hr>");
	 	AccountLocal account2=customer.getAccount();
	 	if(account2!=null)out.println("account2 is not null");
	 	else
	 	out.println("account2 is null");
	 	//out.println(customer.getAccount().getStatus());
	out.println(customer.getAccount().getContactInfo().getEmail());
	 
	
	 //out.println(customer.getAccount().getContactInfo().getEmail());
	
	}
	catch(NamingException e)
	{
	    e.printStackTrace();
	 }
	 

%>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -