亚洲av成人无遮挡网站在线观看,少妇性bbb搡bbb爽爽爽,亚洲av日韩精品久久久久久,兔费看少妇性l交大片免费,无码少妇一区二区三区

Chinaunix

標題: Weblogic下使用jsp查詢的Entity Bean [打印本頁]

作者: linesky    時間: 2011-04-15 00:09
標題: Weblogic下使用jsp查詢的Entity Bean
  1. <%@ page contentType="text/html; charset=GBK" %>
  2. <%@ page import="baisha.*"%>
  3. <%@ page import="javax.naming.*"%>
  4. <%!
  5.   private javax.naming.Context getInitialContext() throws Exception {
  6.     String url = "t3://localhost:7001";
  7.     String user = null;
  8.     String password = null;
  9.     Properties properties = null;
  10.     try {
  11.       properties = new Properties();
  12.       properties.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
  13.       properties.put(Context.PROVIDER_URL, url);
  14.       if (user != null) {
  15.         properties.put(Context.SECURITY_PRINCIPAL, user);
  16.         properties.put(Context.SECURITY_CREDENTIALS, password == null ? "" : password);
  17.       }

  18.       return new InitialContext(properties);
  19.     }
  20.     catch(Exception e) {
  21.       System.out.println(e.getMessage());
  22.       return null;
  23.     }
  24.   }

  25. %>
  26. <html>
  27. <head>
  28. <title>
  29. Jsp1
  30. </title>
  31. </head>
  32. <body>
  33. <%
  34. //Properties env =new Properties();
  35. // env.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
  36. // env.put(Context.INITIAL_CONTEXT_FACTORY,"t3://localhost:7001");
  37. //Context ctx = new InitialContext(env);
  38. String str_id=null;
  39. str_id =request.getParameter("id");
  40. javax.naming.Context ctx = new javax.naming.InitialContext();
  41. Object ref = ctx.lookup("Province");
  42. baisha.ProvinceHome provHome =null;
  43. baisha.Province prov = null;
  44. provHome = (baisha.ProvinceHome)javax.rmi.PortableRemoteObject.narrow(ref,ProvinceHome.class);
  45. if (provHome==null) {
  46.    out.println("provHome is null");
  47. }
  48. else
  49.     {
  50.     if (str_id==null){
  51.    
  52.     }
  53.     else{
  54.       try{
  55.         prov = provHome.findByPrimaryKey(new Integer(str_id));
  56.         out.println(prov.getProvinceName());
  57.         }
  58.       catch(Exception e){
  59.        out.println("ID 不存在!");
  60.       }  
  61.     }
  62.     }
  63.   
  64.      
  65. %>
  66. <h1>
  67. JBuilder Generated JSP
  68. </h1>
  69. <form method="post" action="query.jsp">
  70. <br>Enter new value   :  <input name="id"  type="text"><br>
  71. <br><br>
  72. <input type="submit" name="Submit" value="Submit">
  73. <input type="reset" value="Reset">
  74. <br>

  75. </form>
  76. </body>
  77. </html>
復制代碼





歡迎光臨 Chinaunix (http://72891.cn/) Powered by Discuz! X3.2