Пример #1
0
  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String cateGoryId = request.getParameter("cateGoryId");
    String mobileInterface = utility.getValueFromConfigByKey("mobileinterface");
    String url = mobileInterface + "/getCateGoryInfoLevel.html";
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("cateGoryId", cateGoryId);
    System.out.println("url=" + url);
    String json = JsoupUtil.getJsonStrByPost(url, paramMap);

    response.setContentType("text/plain;charset=UTF-8");
    response.getWriter().write(json);
  }
Пример #2
0
  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String mobileInterface = utility.getValueFromConfigByKey("mobileinterface");
    String schoolId = ConvertUtil.convertNull(request.getParameter("school_id"));

    String url = mobileInterface + "/mobile/getVideosBySchool.html?id=" + schoolId;

    System.out.println("url=" + url);
    String json = loadJson(url);
    System.out.println("json=" + json);
    response.setContentType("text/plain;charset=UTF-8");
    response.getWriter().write(json);
  }
Пример #3
0
/** Servlet implementation class GetChampionVideo */
public class GetChampionVideo extends HttpServlet {
  private static final long serialVersionUID = 1L;
  private Utility utility = Utility.getInstance();

  /** @see HttpServlet#HttpServlet() */
  public GetChampionVideo() {
    super();
    // TODO Auto-generated constructor stub
  }

  /** @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String mobileInterface = utility.getValueFromConfigByKey("mobileinterface");
    String schoolId = ConvertUtil.convertNull(request.getParameter("school_id"));

    String url = mobileInterface + "/mobile/getVideosBySchool.html?id=" + schoolId;

    System.out.println("url=" + url);
    String json = loadJson(url);
    System.out.println("json=" + json);
    response.setContentType("text/plain;charset=UTF-8");
    response.getWriter().write(json);
  }

  /** @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    this.doGet(request, response);
  }

  public static String loadJson(String url) {
    StringBuilder json = new StringBuilder();
    try {
      URL urlObject = new URL(url);
      URLConnection uc = urlObject.openConnection();
      BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(), "UTF-8"));
      String inputLine = null;
      while ((inputLine = in.readLine()) != null) {
        json.append(inputLine);
      }
      in.close();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return json.toString();
  }
}
Пример #4
0
public class CateGoryInfoLevel extends HttpServlet {

  private Utility utility = Utility.getInstance();

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String cateGoryId = request.getParameter("cateGoryId");
    String mobileInterface = utility.getValueFromConfigByKey("mobileinterface");
    String url = mobileInterface + "/getCateGoryInfoLevel.html";
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("cateGoryId", cateGoryId);
    System.out.println("url=" + url);
    String json = JsoupUtil.getJsonStrByPost(url, paramMap);

    response.setContentType("text/plain;charset=UTF-8");
    response.getWriter().write(json);
  }

  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    doGet(request, response);
  }

  public static String loadJson(String url) {
    StringBuilder json = new StringBuilder();
    try {
      URL urlObject = new URL(url);
      URLConnection uc = urlObject.openConnection();
      BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream(), "UTF-8"));
      String inputLine = null;
      while ((inputLine = in.readLine()) != null) {
        json.append(inputLine);
      }
      in.close();
    } catch (MalformedURLException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
    return json.toString();
  }
}