@SuppressWarnings("unchecked") private void handleServletRequest(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { try { ServletRequestInfo info = setServletRequestInfo(request, response); if (request.getMethod().equals("GET")) { List<String> urlParamNames = Collections.list(request.getParameterNames()); HashMap<String, String> params = new HashMap<String, String>(); for (String paramName : urlParamNames) params.put(paramName, request.getParameter(paramName)); JsonRpcRequestModel json = new JsonRpcRequestModel(); json.jsonrpc = JSONRPC_VERSION; json.id = ""; json.method = params.remove(METHOD); json.params = params; info.currentJsonRequest = json; invokeMethod(json.method, params); } else // post { try { String methodName; Object methodParams; if (info.inputStream.peek() == '[' || info.inputStream.peek() == '{') // json { handleArrayOfJsonRequests(info.inputStream, response); } else // AMF3 { ASObject obj = (ASObject) deserializeAmf3(info.inputStream); methodName = (String) obj.get(METHOD); methodParams = obj.get(PARAMS); info.streamParameterIndex = (Number) obj.get(STREAM_PARAMETER_INDEX); invokeMethod(methodName, methodParams); } } catch (IOException e) { sendError(e, null); } catch (Exception e) { sendError(e, null); } } handleJsonResponses(); } finally { removeServletRequestInfo(); } }