public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		/*
		 * name: username, password
		 * return: [{"status":"", "reason":"", "data":""}]
		 * 
		 * request: username, password
		 * response: status (create a session, insert uId into session)
		 */
	
		response.setContentType("text/html");
		PrintWriter out = response.getWriter();
		out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
		out.println("<HTML>");
		out.println("  <HEAD><TITLE>A Servlet</TITLE></HEAD>");
		out.println("  <BODY>");
		out.print("    This is ");
		out.print(this.getClass());
		out.println(", using the POST method");
		out.println("[request.getReader().readLine()]: "); //+ request.getReader().readLine());
		
		// read request body content
		BufferedReader bf = request.getReader();
		String line = bf.readLine();
		StringBuilder sb = new StringBuilder();
		while(line != null) {
			sb.append(line);
			line = bf.readLine();
		}
		String json = sb.toString();
		out.println(json);
		
		// decode the json text from the content of request
		JSONParser parser = new JSONParser();
		Object obj = null;
		try {
			obj = parser.parse(json);
		} catch (ParseException e) {
			e.printStackTrace();
		}
		JSONArray array = (JSONArray) obj;
		out.println("======the 1 element of array======");
		out.println(array.get(0));
		out.println();

		JSONObject obj2 = (JSONObject) array.get(0);
		out.println("======field \"b\"==========");
		out.println(obj2.get("id"));
		
		out.println("======field \"id\"==========");
		String ids = (String)obj2.get("id");
		String[] id_array = ids.split(",");
		for(String s : id_array) {
			out.println(s);
		}
		
		DealsDAO dealsDAO = new DealsDAO();
		List<Deals> deals = new ArrayList<Deals>();
		for (String s : id_array) {
			int id = parseInteger(s);
			Deals deal = null;
			if (id == -1) {
				//TODO response err
			}
			else {
				deal = dealsDAO.selectById(id);	
			}
			deals.add(deal);
		}
		out.println("<h4>Deals:</h4>");
		for (int i=0; i<deals.size(); i++){
			out.println("Index "+ (i+1) +": ");
			String str = deals.get(i).toString();
			str=new String(str.getBytes("utf-8"),"8859_1");
			out.println(str);
			out.println("<br />");
		}
		out.println("=============================================");
		out.println("<br />");
		
		out.println(convertEncoding(convertDealsToJson(deals)));
		
		out.println("  </BODY>");
		out.println("</HTML>");
		out.flush();
		out.close();
	}