public void getJSONObject(JSONObject jso) throws JSONException {

    net.sf.json.JSONObject map = new net.sf.json.JSONObject();
    map.putAll(_scoreMap);

    jso.put("scores", map.toString());
  }
  public JSONArray getUserTimezoneHistory(
      UpdateInfo updateInfo, String api_key, OAuthConsumer consumer) throws Exception {
    long then = System.currentTimeMillis();
    String requestUrl = "http://api.bodymedia.com/v2/json/timezone?api_key=" + api_key;

    HttpGet request = new HttpGet(requestUrl);
    consumer.sign(request);
    HttpClient client = env.getHttpClient();
    enforceRateLimits(getRateDelay(updateInfo));
    HttpResponse response = client.execute(request);
    final int statusCode = response.getStatusLine().getStatusCode();
    final String reasonPhrase = response.getStatusLine().getReasonPhrase();
    if (statusCode == 200) {
      countSuccessfulApiCall(updateInfo.apiKey, updateInfo.objectTypes, then, requestUrl);
      ResponseHandler<String> responseHandler = new BasicResponseHandler();
      String json = responseHandler.handleResponse(response);
      JSONObject userInfo = JSONObject.fromObject(json);
      return userInfo.getJSONArray("timezones");
    } else {
      countFailedApiCall(
          updateInfo.apiKey,
          updateInfo.objectTypes,
          then,
          requestUrl,
          "",
          statusCode,
          reasonPhrase);
      throw new Exception(
          "Error: "
              + statusCode
              + " Unexpected error trying to bodymedia timezone for user "
              + updateInfo.apiKey.getGuestId());
    }
  }
示例#3
0
 public static Integer getGameCode(String content) {
   if (StringUtils.isNotBlank(content)) {
     JSONObject obj = JSONObject.fromObject(content);
     return obj.getInt("code");
   }
   return -1000;
 }
 public JrdwMonitorVo toJrdwMonitor(int id, String jobId) throws Exception {
   JrdwMonitorVo jmv = new JrdwMonitorVo();
   jmv.setId(id);
   jmv.setJrdw_mark(jobId);
   // pack the member / value  to the Map<String,String> or Map<String,Long>
   Map<String, Long> content = new HashMap<String, Long>();
   switch (id) {
     case JDMysqlTrackerPhenix.FETCH_MONITOR:
       content.put(JDMysqlTrackerPhenix.FETCH_ROWS, fetchNum);
       content.put(JDMysqlTrackerPhenix.FETCH_SIZE, batchSize);
       break;
     case JDMysqlTrackerPhenix.PERSIS_MONITOR:
       content.put(JDMysqlTrackerPhenix.SEND_ROWS, persisNum);
       content.put(JDMysqlTrackerPhenix.SEND_SIZE, batchSize);
       content.put(JDMysqlTrackerPhenix.SEND_TIME, (sendEnd - sendStart));
       content.put(JDMysqlTrackerPhenix.DELAY_TIME, delayTime);
       break;
     default:
       break;
   }
   // map to json
   JSONObject jo = JSONConvert.MapToJson(content);
   jmv.setContent(jo.toString());
   return jmv;
 }
示例#5
0
  public ActionForward getBillingDxAutocompleteList(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    DiagnosticCodeDao diagnosticCodeDao =
        (DiagnosticCodeDao) SpringUtils.getBean("diagnosticCodeDao");

    String query = request.getParameter("query");

    List<DiagnosticCode> queryResults =
        diagnosticCodeDao.findByDiagnosticCodeAndRegion(query, "ON");
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    hashMap.put("dxCode", queryResults);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
  private static JSONObject extractVuserResult(Map<Integer, TreeMap<String, Integer>> graphData) {
    JSONObject graphDataSet;
    graphDataSet = new JSONObject();
    JSONArray labels = new JSONArray();

    HashMap<String, ArrayList<Number>> vUserState = new HashMap<String, ArrayList<Number>>(0);
    vUserState.put("Passed", new ArrayList<Number>(0));
    vUserState.put("Failed", new ArrayList<Number>(0));
    vUserState.put("Stopped", new ArrayList<Number>(0));
    vUserState.put("Error", new ArrayList<Number>(0));
    for (Map.Entry<Integer, TreeMap<String, Integer>> run : graphData.entrySet()) {
      Number tempVUserCount = run.getValue().get("Count");
      if (tempVUserCount != null && tempVUserCount.intValue() > 0) {
        labels.add(run.getKey());
        vUserState.get("Passed").add(run.getValue().get("Passed"));
        vUserState.get("Failed").add(run.getValue().get("Failed"));
        vUserState.get("Stopped").add(run.getValue().get("Stopped"));
        vUserState.get("Error").add(run.getValue().get("Error"));
      }
    }

    graphDataSet.put(LABELS, labels);
    graphDataSet.put(SERIES, createGraphDatasets(vUserState));
    return graphDataSet;
  }
示例#7
0
  /**
   * 分享直播
   *
   * @param liveId
   * @param group
   * @param currUser
   * @return
   * @throws XueWenServiceException
   */
  public boolean share(String liveId, String source, User currUser) throws XueWenServiceException {
    Live liveResult = liveRepo.findOne(liveId);
    if (liveResult == null) {
      throw new XueWenServiceException(Config.STATUS_201, Config.MSG_NODATA_201, null);
    }
    List<JSONObject> newAddGroups = new ArrayList<JSONObject>();
    if (!StringUtil.isBlank(source)) {
      List<JSONObject> groupList = JSON2ObjUtil.getDTOList(source, JSONObject.class);
      newAddGroups.addAll(groupList);
      List<JSONObject> oldGroup = liveResult.getGroup();
      // 取新增的群组
      newAddGroups.removeAll(oldGroup);
      liveResult.getGroup().addAll(newAddGroups);
    }

    liveRepo.save(liveResult);
    for (JSONObject obj : newAddGroups) {
      try {
        // 创建群组动态
        this.createGroupDynamic(liveResult, obj.getString("groupId"));
      } catch (Exception e) {
        l.error("======创建活动群组动态失败:========" + e);
      }
    }
    return true;
  }
 /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
 protected void doGet(HttpServletRequest request, HttpServletResponse response)
     throws ServletException, IOException {
   JSONObject reqJSON = StringUtil.fromReaderToJSON(request.getReader());
   JSONObject result = dao.uploadImage(reqJSON);
   response.setContentType("text/json;charset=UTF-8");
   response.getWriter().write(result.toString());
 }
示例#9
0
  void processSetProperties(JSONObject data) {
    final String tokenId = data.getString("tokenId");
    final Token token = findTokenFromId(tokenId);
    final Zone zone = findZoneTokenIsOn(token);

    if (token == null) {
      System.out.println("DEBUG: sendTokenInfo(): Unable to find token " + tokenId);
      return;
      // FIXME: log this error
    }

    final JSONObject props = data.getJSONObject("properties");
    EventQueue.invokeLater(
        new Runnable() {
          @Override
          public void run() {
            Set<String> pnames = props.keySet();
            for (String pname : pnames) {
              String val = props.getString(pname);
              token.setProperty(pname, val);
            }

            zone.putToken(token);
          }
        });
  }
    @Override
    public synchronized boolean configure(StaplerRequest req, JSONObject formData)
        throws FormException {

      // The following codes are bad...
      // How to bind formData to List<Discriptor> ?

      if (nexusMap == null) {
        nexusMap = new HashMap<String, NexusDescriptor>();
      }

      try {
        JSONObject json = formData.getJSONObject("nexusList");
        nexusMap.clear();
        NexusDescriptor desc = parse(json);
        nexusMap.put(desc.getName(), desc);
      } catch (JSONException e) {
        try {
          JSONArray jsons = formData.getJSONArray("nexusList");
          nexusMap.clear();
          for (Object json : jsons) {
            NexusDescriptor desc = parse((JSONObject) json);
            nexusMap.put(desc.getName(), desc);
          }
        } catch (JSONException ee) {
          // exec in this path only if nexusList is empty.
        }
      }

      save();
      return super.configure(req, formData);
    }
 private NexusDescriptor parse(JSONObject json) {
   return new NexusDescriptor(
       json.getString("name"),
       json.getString("url"),
       json.getString("user"),
       json.getString("password"));
 }
示例#12
0
  public List<AppModel> getAppById(String id) {
    String cql = "SELECT * FROM app WHERE appid = '%s';";
    cql = String.format(cql, id);
    List<AppModel> apps = new ArrayList<AppModel>();
    Iterator rows = this.bridge.excute(cql);
    while (rows.hasNext()) {
      AppModel app = new AppModel();
      Row row = (Row) rows.next();
      app.setAppid(row.getString("appid"));
      app.setName(row.getString("name"));
      app.setInstallUrl(row.getString("url"));
      app.setProfile(row.getString("profile"));
      app.setIsInnerApp(row.getString("isinnerapp"));

      try {
        JSONObject profile = JSONObject.fromObject(app.getProfile());
        app.setImage(profile.getString("image"));
        apps.add(app);
      } catch (Exception e) {
        log.error(e.getMessage());
        e.printStackTrace();
      }
    }
    return apps;
  }
示例#13
0
 public String getSuccessString(String API_CODE, JSONObject temp) {
   JSONArray jarray = new JSONArray();
   temp.put("status", "0");
   temp.put("msg", API_CODE + "00");
   jarray.add(temp);
   return jarray.toString();
 }
示例#14
0
 // 上传文件
 public String upLoadOne() throws Exception {
   JSONObject jsonObject = new JSONObject();
   String id = ((String[]) formMap.get("id"))[0] + ""; // 获取id
   String uploadName = ((String[]) formMap.get("uploadName"))[0] + ""; // 获取id
   ReptTechDtl rt = techReptDtlService.get(Long.parseLong(id)); // dtl
   try {
     String targetDirectory =
         getTechPath() + rt.getTechReptDef().getId() + rt.getTechReptDef().getName();
     String temArr[] = uploadName.split("\\.");
     String fileName = UUID.randomUUID().toString(); // 读取
     if (temArr.length != 0) {
       fileName = fileName + "." + temArr[temArr.length - 1];
     }
     File target = new File(targetDirectory, fileName);
     FileUtils.copyFile(formFile, target);
     // 更新技办人 和上传名称和实际存放的名称
     rt.setTekofficer(getCurUser().getName()); //
     rt.setUploadName(uploadName);
     rt.setSaveName(fileName);
     rt.setUpdDate(DateUtil.dateToDateByFormat(utilService.getSysTime(), DateUtil.FORMAT));
     techReptDtlService.save(rt);
   } catch (Exception e) {
     e.printStackTrace();
     jsonObject.put("result", false);
     json = jsonObject.toString();
     return EASYFILE;
   }
   jsonObject.put("result", true);
   json = jsonObject.toString();
   return EASYFILE;
 }
  @Override
  public void handleData() {
    // TODO Auto-generated method stub
    Message message =
        MessageManager.createMessage(cassandraClient, appId, userId, toUserId, messageContent);
    String messageId = message.getMessageId();
    MessageManager.createUserPostIndex(cassandraClient, userId, toUserId, messageId);

    List<HColumn<String, String>> clist =
        cassandraClient.getColumnKey(
            DBConstants.USER, toUserId, DBConstants.F_NICKNAME, DBConstants.F_AVATAR);
    String nickName = null;
    String avatar = null;
    for (int i = 0; i < clist.size(); i++) {
      HColumn<String, String> column = clist.get(i);
      if (column.getName().equals(DBConstants.F_NICKNAME)) {
        nickName = column.getValue();
      } else if (column.getName().equals(DBConstants.F_AVATAR)) {
        avatar = column.getValue();
      }
    }
    String createDate = message.getCreateDate();
    JSONObject obj = new JSONObject();
    obj.put(ServiceConstant.PARA_MESSAGE_ID, messageId);
    obj.put(ServiceConstant.PARA_NICKNAME, nickName);
    obj.put(ServiceConstant.PARA_AVATAR, avatar);
    obj.put(ServiceConstant.PARA_CREATE_DATE, createDate);
    resultData = obj;
  }
 @Override
 public boolean configure(StaplerRequest req, JSONObject formData) throws FormException {
   setTenantRepositoryDirPattern(formData.getString("tenantRepositoryDirPattern"));
   setPreConfiguredMvnRepoArchive(formData.getString("preConfiguredMvnRepoArchive"));
   save();
   return super.configure(req, formData);
 }
  private static JSONObject extractAvgTrtData(
      Map<Integer, TreeMap<String, AvgTransactionResponseTime>> graphData,
      HashSet<String> transactions) {
    HashMap<String, ArrayList<Number>> averageTRTData = new HashMap<String, ArrayList<Number>>(0);
    JSONObject graphDataSet = new JSONObject();

    JSONArray labels = new JSONArray();

    for (String transaction : transactions) {
      averageTRTData.put(transaction, new ArrayList<Number>(0));
    }

    for (Map.Entry<Integer, TreeMap<String, AvgTransactionResponseTime>> result :
        graphData.entrySet()) {
      labels.add(result.getKey());

      for (String transaction : transactions) {
        if (!result.getValue().containsKey(transaction)) {
          averageTRTData.get(transaction).add(null);
          // TODO:change to null
          continue;
        }
        averageTRTData
            .get(transaction)
            .add((result.getValue()).get(transaction).getActualValueAvg());
      }
    }

    graphDataSet.put(LABELS, labels);
    JSONArray datasets = createGraphDatasets(averageTRTData);
    graphDataSet.put(SERIES, datasets);
    return graphDataSet;
  }
 @Function("public")
 public void doQuery(
     Context context, @Param(name = "from") String from, @Param(name = "to") String to) {
   try {
     Date start = new Date();
     Date end = new Date();
     if (from == null || to == null) {
       end = new Date();
       Calendar calendar = Calendar.getInstance();
       calendar.setTime(end);
       calendar.add(Calendar.DATE, -1); // 得到前一天
       start = calendar.getTime();
     } else {
       SimpleDateFormat fmt = new SimpleDateFormat("MM/dd/yyyy");
       start = fmt.parse(from);
       end = fmt.parse(to);
     }
     EucaConsoleMessage message = eucaAC.genVolumeReport(start, end);
     JSONObject object = (JSONObject) message.getData();
     JSONArray resluts = object.getJSONArray("reports");
     context.put("json", resluts);
   } catch (Exception e) {
     logger.error(e.getMessage(), e);
   }
 }
  private static JSONObject extractPercentileTransactionSet(
      Map<Integer, TreeMap<String, PercentileTransactionWholeRun>> graphData,
      HashSet<String> transactions) {
    JSONObject graphDataSet = new JSONObject();
    JSONArray labels = new JSONArray();

    HashMap<String, ArrayList<Number>> percentileTrtData =
        new HashMap<String, ArrayList<Number>>(0);
    for (String transaction : transactions) {
      percentileTrtData.put(transaction, new ArrayList<Number>(0));
    }

    for (Map.Entry<Integer, TreeMap<String, PercentileTransactionWholeRun>> result :
        graphData.entrySet()) {
      labels.add(result.getKey());

      for (String transaction : transactions) {
        if (!result.getValue().containsKey(transaction)) {
          percentileTrtData.get(transaction).add(null);
          // TODO:change to null
          continue;
        }
        percentileTrtData
            .get(transaction)
            .add((result.getValue()).get(transaction).getActualValue());
      }
    }

    graphDataSet.put(LABELS, labels);
    graphDataSet.put(SERIES, createGraphDatasets(percentileTrtData));

    return graphDataSet;
  }
示例#20
0
 @Override
 public String toString() {
   JSONObject json = new JSONObject();
   json.put("x", x);
   json.put("y", y);
   return json.toString();
 }
示例#21
0
 /*
  * ajax修改角色
  * 返回json
  */
 @Action(
     value = "/role/editRole",
     interceptorRefs = {@InterceptorRef("roleInterceptor")},
     results = {
       @Result(name = "noLogin", type = "chain", location = "loginErrorAjax"),
       @Result(name = "noRoleAuthority", type = "chain", location = "noAuthorityAjax")
     })
 public String editRole() throws Exception {
   result = new JSONObject();
   role = new Role(false);
   if (roleName != null && roleId != null) {
     role.setRoleId(Integer.parseInt(roleId));
     role.setRoleName(roleName);
     if (roleDescription != null) {
       role.setRoleDescription(roleDescription);
     }
     role.setRoleStatus(roleState);
     StringUtil.String2RoleAuthority(roleAuthority, role);
     roleService.updateRole(role);
     result.put("result", 1);
     if (role.getRoleStatus() == 1) {
       request.getServletContext().setAttribute("role_" + roleId, role);
     }
   } else {
     result.put("result", 2);
   }
   return "json";
 }
示例#22
0
  protected void check(String layoutName, String lang) throws Exception {
    LayoutConversionContext ctx = new LayoutConversionContext(lang, null);
    LayoutDefinition layoutDef =
        service.getLayoutDefinition(WebLayoutManager.JSF_CATEGORY, layoutName);
    Layout layout =
        jsfService.getLayout(
            null, ctx, TEST_CATEGORY, layoutDef, BuiltinModes.VIEW, "currentDocument", null, false);
    String langFilePath = lang;
    if (langFilePath == null) {
      langFilePath = "nolang";
    }
    File file = Framework.createTempFile("layout-instance-export-" + langFilePath, ".json");
    FileOutputStream out = new FileOutputStream(file);
    JSONObject res = JSONLayoutExporter.exportToJson(layout);
    out.write(res.toString(2).getBytes(JSONLayoutExporter.ENCODED_VALUES_ENCODING));
    out.close();

    InputStream written = new FileInputStream(file);
    InputStream expected =
        new FileInputStream(
            FileUtils.getResourcePathFromContext(
                "layout-instance-export-" + langFilePath + ".json"));

    String expectedString = IOUtils.toString(expected, Charsets.UTF_8);
    String writtenString = IOUtils.toString(written, Charsets.UTF_8);
    // order of select options may depend on directory database => do not
    // check order of element by using the NON_EXTENSIBLE mode
    JSONAssert.assertEquals(expectedString, writtenString, JSONCompareMode.NON_EXTENSIBLE);
  }
示例#23
0
  public ActionForward getBillingAutocompleteList(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    BillingServiceDao billingServiceDao =
        (BillingServiceDao) SpringUtils.getBean("billingServiceDao");

    String query = request.getParameter("query");

    List<BillingService> queryResults =
        billingServiceDao.findBillingCodesByCode("%" + query + "%", "ON", new Date(), 1);
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    hashMap.put("billing", queryResults);

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
示例#24
0
 public JSONObject jsonify() {
   JSONObject ret = super.jsonify();
   ret.element("type", "monthly");
   ret.element("dayOfWeek", getDayOfWeek());
   ret.element("weekOfMonth", getWeekOfMonth());
   return ret;
 }
示例#25
0
  public ActionForward updateAppointmentReason(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    HashMap<String, Object> hashMap = new HashMap<String, Object>();

    OscarAppointmentDao appointmentDao =
        (OscarAppointmentDao) SpringUtils.getBean("oscarAppointmentDao");

    Appointment appointment =
        appointmentDao.find(Integer.parseInt(request.getParameter("appointmentNo")));

    if (appointment != null) {
      appointment.setReason(request.getParameter("reason"));
      appointmentDao.merge(appointment);

      hashMap.put("success", true);
      hashMap.put("appointmentNo", appointment.getId());
    }

    JsonConfig config = new JsonConfig();
    config.registerJsonBeanProcessor(java.sql.Date.class, new JsDateJsonBeanProcessor());

    JSONObject json = JSONObject.fromObject(hashMap, config);
    response.getOutputStream().write(json.toString().getBytes());

    return null;
  }
示例#26
0
  /**
   * 获取jsapi_ticket
   *
   * @param accesstoken
   * @return
   */
  public static void getjsTicket(String accesstoken) {

    String jsapi_ticketUrl =
        "https://api.weixin.qq.com/cgi-bin/ticket/getticket?access_token=ACCESS_TOKEN&type=jsapi";
    String url = jsapi_ticketUrl.replace("ACCESS_TOKEN", accesstoken);
    System.out.println("查看js_url:" + url);

    try {
      if (jsTicket.equals("")) {
        String result = HttpUtil.getInstance().execGet(url);
        logger.debug("result==" + result);

        JSONObject obj = JSONObject.fromObject(result);

        if (obj.containsKey("ticket")) {
          jsTicket = obj.get("ticket").toString();
          System.out.println("ticket====" + obj.get("ticket"));
        } else {
          getAccessToken();
          getjsTicket(accessToken);
          return;
        }
      } else {

      }
    } catch (ClientProtocolException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
示例#27
0
 @SuppressWarnings("unchecked")
 public static <T> T str2Obj(String content, Class<T> cls) {
   if (StringUtils.isNotBlank(content)) {
     return (T) JSONObject.toBean(JSONObject.fromObject(content), cls);
   }
   return null;
 }
  /** Web method to handle the approval action submitted by the user. */
  public void doApprove(
      StaplerRequest req,
      StaplerResponse rsp,
      @AncestorInPath PromotionProcess promotionProcess,
      @AncestorInPath AbstractBuild<?, ?> build)
      throws IOException, ServletException {

    JSONObject formData = req.getSubmittedForm();

    if (canApprove(promotionProcess, build)) {
      List<ParameterValue> paramValues = new ArrayList<ParameterValue>();

      if (parameterDefinitions != null && !parameterDefinitions.isEmpty()) {
        JSONArray a = JSONArray.fromObject(formData.get("parameter"));

        for (Object o : a) {
          JSONObject jo = (JSONObject) o;
          String name = jo.getString("name");

          ParameterDefinition d = getParameterDefinition(name);
          if (d == null)
            throw new IllegalArgumentException("No such parameter definition: " + name);

          paramValues.add(d.createValue(req, jo));
        }
      }
      approve(build, promotionProcess, paramValues);
    }

    rsp.sendRedirect2("../../../..");
  }
示例#29
0
  public static void main(String[] args) {
    List<Map<String, Integer>> list = new ArrayList<Map<String, Integer>>();
    for (int i = 24; i <= 28; i++) {
      Map<String, Integer> map = new HashMap<String, Integer>();
      map.put("day", i);
      map.put("havedata", 0);
      list.add(map);
    }
    Random r = new Random();
    for (int i = 1; i <= 31; i++) {
      Map<String, Integer> map = new HashMap<String, Integer>();
      map.put("day", i);
      map.put("havedata", 1);
      map.put("nowfee", 3216 + r.nextInt(1000000));
      map.put("oldfee", 3216 + r.nextInt(1000000));
      map.put("dau", 3216 + r.nextInt(1000000));
      map.put("dnu", 3216 + r.nextInt(1000000));
      list.add(map);
    }
    for (int i = 1; i <= 6; i++) {
      Map<String, Integer> map = new HashMap<String, Integer>();
      map.put("day", i);
      map.put("havedata", 0);
      list.add(map);
    }
    System.out.println(array2JsonString(list));

    String json =
        "{\"code\":0,\"info\":\"success\",\"data\":{\"systemMail\":{\"mailVer\":19,\"target\":0,\"condition\":0,\"value\":2,\"title\":\"???è?????é??\",\"content\":\"???è?????é?????è?????é??\",\"sendTime\":1402555848,\"award\":{\"awardId\":0,\"gold\":2,\"heart\":2,\"diamond\":333,\"items\":[12,123],\"itemsCount\":[1,2]}}},\"sys_time\":1402555848}";
    JSONObject obj = getObj(json);
    System.out.println(obj.getJSONObject("data").getJSONObject("systemMail").getInt("mailVer"));
    System.out.println(obj.getInt("code"));
  }
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, java.io.IOException {

    String code = request.getParameter("code");
    String Token = (String) request.getSession().getAttribute("accessToken");
    System.out.println("accessToken" + Token);
    String requestUrl =
        "https://graph.renren.com/oauth/token?grant_type=authorization_code&client_id="
            + client_ID
            + "&redirect_uri=http://other.internetrt.org:8080/renrent/home&client_secret="
            + client_SECRET
            + "&code="
            + code;
    String result = httpClientPost(requestUrl);

    System.out.println("[HomeServlet : doPost]" + result);
    try {
      JSONObject json = JSONObject.fromString(result);
      String sessionKey = (String) json.get("access_token");
      System.out.println("[HomeServlet : doPost]: " + "renrenSessionKey: " + sessionKey);
      request.setAttribute("sessionkeyfromrenren", sessionKey);
      System.out.println("[HomeServlet : doPost]: " + "renrenSessionKey" + sessionKey);
      ApiInitListener.feedstub.addFeedUser(sessionKey, Token);
    } catch (Exception err) {
      err.printStackTrace();
      System.out.println("[HomeServlet : doPost] json串问题");
    }

    RequestDispatcher welcomeDispatcher = request.getRequestDispatcher("/views/home.jsp");
    welcomeDispatcher.forward(request, response);
  }