Java,J2EE,Weblogic,Oracle

java项目随笔
随笔 - 90, 文章 - 6, 评论 - 61, 引用 - 0
数据加载中……

虚拟提交

<%@ page language="java" import="java.util.*,java.net.*,java.io.*" pageEncoding="GBK"%>
<%@ page import="java.util.Enumeration" %>


<% 
  try {
    //应用服务器地址
         //ResourceBundle pro = ResourceBundle.getBundle("ctii-unicall");
   //String ipaddrs=ParamServiceImpl.getInstance().getConfValue(pro.getString("PortalWeb_IP"));
//   String[] szServers={"10.10.16.238:8080"};
   String[] szServers={"10.10.4.102:8100","10.10.4.122:8100","10.10.4.102:8200","10.10.4.122:8200"};
       
   String HKServerAddr = request.getRemoteAddr();
  //if((HKServerAddr == null)||(!HKServerAddr.trim().equals("202.82.183.163"))) {
   if((HKServerAddr == null)) {
     out.println("0");
     out.println("RemoteIP: " + HKServerAddr);
     System.out.println("RemoteIP: " + HKServerAddr);
     return;
   }
   
   String method = request.getParameter("method");
   String username = request.getParameter("username");
   String billno = request.getParameter("id"); 
   
   
   
   /***********************/
        //并发送给各个的服务器(包括自己)
        URL destURL;
        HttpURLConnection urlConn;
        String myPostParam;
        for(int i=0; i<szServers.length; i++) {
         if(billno != null ) {
    //out.println("<br>IP: " + java.net.InetAddress.getLocalHost().getHostAddress() + "; servers:" + szServers[i] + "<br>");
   }
         try{
            // Send HK current login user SESSION_ID & HK current login account to SZ Host
            String HKmethod = "method="+method.toString();
            // Can Modify to get UserID from http-session
  //          String HKAccount = "&mcd="+URLEncoder.encode("1001209", "UTF-8");         
            String HKusername = "&username="+username.toString();
            String HKid = "&id="+billno.toString();
           
             myPostParam = HKmethod + HKusername + HKid;
             System.out.println(szServers[i]);
             destURL = new URL("http://"+szServers[i]+"/bc/application/openToAllServers.jsp");
             urlConn = (HttpURLConnection)destURL.openConnection();
             urlConn.setRequestMethod("POST");
             urlConn.setDoOutput(true);     // 需要向服务器写数据
             urlConn.setDoInput(true);      //
             urlConn.setUseCaches(false);   // 获得服务器最新的信息
             urlConn.setAllowUserInteraction(false);
             urlConn.setRequestProperty("Content-type","application/x-www-form-urlencoded");
             // 必须告诉服务器你发送的数据大小. 这也同样告诉
             urlConn.setRequestProperty("Content-length", ""+myPostParam.length());
             // Open an output stream so you can send the info you are posting
             DataOutputStream outStream = new DataOutputStream(urlConn.getOutputStream());
             // Write out the actual request data
             outStream.writeBytes(myPostParam);
             outStream.flush();
                    
             BufferedReader inReader = new BufferedReader(new InputStreamReader(urlConn.getInputStream()));

             String sRet;
             //int iii = 0;
             while ((sRet = inReader.readLine()) != null) {               
       if(billno != null) {
                  out.print(sRet);  
              } else if(!sRet.trim().equals("")) break;
          }
             outStream.close();    
             inReader.close();
         }catch(Exception e){
             System.out.println("openOrunopen.jsp 同步 application Error:"+e);
             //out.println("0");
             //out.println("<br>同步 application 错误:" + e);
             return;
          }
        } // end for
       
 
 
 
  
  } catch (Exception e1) {
  out.println("0");
  out.println("error:<br>" +  e1);
  return;
 }
  
 
%>

posted on 2007-09-04 19:10 龚椿深 阅读(245) 评论(0)  编辑  收藏


只有注册用户登录后才能发表评论。


网站导航: