protected void doPost(HttpServletRequest req, HttpServletResponse resp)
throws ServletException, IOException {
System.out.println(req.getParameter("initArgs"));
HttpSession session = req.getSession();
String server = req.getParameter("server");
//String command = req.getParameter("command");
//System.out.println(command);
LoadConfig load = new LoadConfig();
Properties properties = load.getServerArgs();
URL url = new URL(load.getServer(server));
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
//String info = "";
try{
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-type", "application/x-java-serialized-object");
connection.setRequestProperty("accept", "text/xml;text/html");
connection.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
connection.setRequestMethod("POST");
connection.connect();
synchronized (this) {
os = new OutputStreamWriter(connection.getOutputStream(),"utf-8");
String key = load.getKey("key");
Date date = new Date();
String time = ""+date.getTime();
String md5Code = new Md5().getMd5((time+key).getBytes());
System.out.println("请求的MD5: "+md5Code);
Iterator it = properties.entrySet().iterator();
String command = "";
String info = "";
List commandlist = new ArrayList();
int i = 1;
while(it.hasNext()){
System.out.println("正在初始化第"+i+"条配置");
Map.Entry entry=(Map.Entry)it.next();
command = "setServerConfig "+entry.getKey()+" "+entry.getValue();
os.write("command="+command+"&time="+time+"&flag="+md5Code);
//System.out.println("本次请求参数: command="+command+"&time="+time+"&flag="+md5Code);
os.flush();
is = connection.getInputStream();
br= new BufferedReader(new InputStreamReader(is));
if((info = br.readLine())!= null){
System.out.println(info); //这里第一次有值,后面全为NULL了
commandlist.add(info);
session.setAttribute("commandlist", commandlist);
}
this.wait(500);
i++;
command= "";
}
}
throws ServletException, IOException {
System.out.println(req.getParameter("initArgs"));
HttpSession session = req.getSession();
String server = req.getParameter("server");
//String command = req.getParameter("command");
//System.out.println(command);
LoadConfig load = new LoadConfig();
Properties properties = load.getServerArgs();
URL url = new URL(load.getServer(server));
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
//String info = "";
try{
connection.setDoOutput(true);
connection.setDoInput(true);
connection.setUseCaches(false);
connection.setRequestProperty("Content-type", "application/x-java-serialized-object");
connection.setRequestProperty("accept", "text/xml;text/html");
connection.setRequestProperty("Content-Type", "text/xml;charset=utf-8");
connection.setRequestMethod("POST");
connection.connect();
synchronized (this) {
os = new OutputStreamWriter(connection.getOutputStream(),"utf-8");
String key = load.getKey("key");
Date date = new Date();
String time = ""+date.getTime();
String md5Code = new Md5().getMd5((time+key).getBytes());
System.out.println("请求的MD5: "+md5Code);
Iterator it = properties.entrySet().iterator();
String command = "";
String info = "";
List commandlist = new ArrayList();
int i = 1;
while(it.hasNext()){
System.out.println("正在初始化第"+i+"条配置");
Map.Entry entry=(Map.Entry)it.next();
command = "setServerConfig "+entry.getKey()+" "+entry.getValue();
os.write("command="+command+"&time="+time+"&flag="+md5Code);
//System.out.println("本次请求参数: command="+command+"&time="+time+"&flag="+md5Code);
os.flush();
is = connection.getInputStream();
br= new BufferedReader(new InputStreamReader(is));
if((info = br.readLine())!= null){
System.out.println(info); //这里第一次有值,后面全为NULL了
commandlist.add(info);
session.setAttribute("commandlist", commandlist);
}
this.wait(500);
i++;
command= "";
}
}
while(it.hasNext()){