public void save_param(HttpServletRequest request, HttpServletResponse response) throws IOException { String uuid = this.getStringParam(request, "uuid", null); String param = this.getStringParam(request, "param", null); final Map<String, String> result = new HashMap<String, String>(); result.put("status", "error"); if (uuid == null || param == null) { result.put("msg", "-2:Parameter error"); } else { String[] p = param.split(","); byte[] bParam = new byte[p.length]; for (int i = 0; i < p.length; i++) { bParam[i] = Byte.parseByte(p[i]); } ASC100Client ascClient = server.getMonitorClient(uuid); if (ascClient == null) { result.put("msg", "1$Not found base station"); } else { result.put("status", "timeout"); ImageClientListener l = new AbstractImageListener() { public void message(ImageClientEvent event) { if (event.data.len == 2) { ByteBuffer b = event.data.inBuffer.asReadOnlyBuffer(); if (b.get() == 1) { result.put("status", "ok"); synchronized (this) { this.notifyAll(); } } } }; }; ascClient.addListener(l); try { this.log.debug(String.format("Set image param:%s", param)); if (ascClient.saveParam(bParam)) { synchronized (l) { l.wait(1000 * 10); } } else { result.put("status", "image"); } } catch (InterruptedException e) { } finally { ascClient.removeListener(l); } } } JSONValue.writeJSONString(result, response.getWriter()); }