address.jsp

来自「《J2EE企业级应用开发》一书的配套源代码」· JSP 代码 · 共 40 行

JSP
40
字号
<%@ page import="java.io.IOException,java.util.*,javax.naming.*,javax.servlet.*,
javax.servlet.http.*,javax.rmi.PortableRemoteObject,com.j2eeapp.ch21.cmp.*" %>

<%    
	try
      {
         // Get a naming context
         InitialContext jndiContext = new InitialContext();

          Object ref  = jndiContext.lookup("ejb/address_cmp");
          if(ref!=null)
          {
          out.println("ok");
          }

         // Get a reference from this to the Bean's Home interface
         AddressHome home = (AddressHome)PortableRemoteObject.narrow(ref,AddressHome.class);
	
      // Address address = home.create("shao yao ju","beijing","beiing_state" ,"100013");
      Collection c=home.queryAll();
      Iterator it=c.iterator();
      while(it.hasNext())
      {
        Address address=(Address)it.next();
        out.println(address.getState()+address.getCity()+address.getZip());
      }
     
      // out.println("created");
      
      // out.println(address.getState()+address.getCity()+address.getZip());
	 	}
	  catch(Exception e)
      {
         out.println(e.toString());
      }
      
  out.println("sucess");

%>

⌨️ 快捷键说明

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