protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		JSONObject jb = new JSONObject();
		String userId = request.getParameter("userId");
		try{
			connection = new Mongo();
			scheduleDB = connection.getDB("schedule");
			groupCollection = scheduleDB.getCollection("group_" + userId);
			DBObject friendsQuery = new BasicDBObject();
			friendsQuery.put("groupName", "All friends");
			DBCursor cur = groupCollection.find(friendsQuery);
			JSONArray friendsArray = new JSONArray();
			JSONArray friends = new JSONArray();
			while(cur.hasNext()){
				DBObject dbo = cur.next();
				try {
					friends = new JSONArray(dbo.get("member").toString());
					for(int i =0; i <friends.length(); i++){
						DBCollection userCollection = scheduleDB.getCollection("user");
						DBObject userQuery = new BasicDBObject();
						String friendId = (String)friends.get(i);
						userQuery.put("_id", new ObjectId(friendId));
						DBCursor userCur = userCollection.find(userQuery);
						if(userCur.hasNext()){
							DBObject friendDBObject = userCur.next();
							JSONObject friendJSONObject = new JSONObject();
							String friendName = (String)friendDBObject.get("username");
							String friendImage = (String)friendDBObject.get("image");
							friendJSONObject.put("friendId", friendId);
							friendJSONObject.put("friendName", friendName);
							friendJSONObject.put("friendImage", friendImage);
							friendsArray.put(friendJSONObject);
						}
					}
					jb.put("friendsArray", friendsArray);
					jb.put("result", Primitive.ACCEPT);
				}catch(NullPointerException npe){
					JSONArray emptyFriendsArray = new JSONArray();
					try {
						jb.put("friendsArray", emptyFriendsArray);
						jb.put("result", Primitive.ACCEPT);
					} catch (JSONException e) {
						// TODO Auto-generated catch block
						e.printStackTrace();
					}
				}catch (JSONException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			}
		}catch(MongoException e){
			try {
				jb.put("result", Primitive.DBCONNECTIONERROR);
			} catch (JSONException e1) {
				// TODO Auto-generated catch block
				e1.printStackTrace();
			}
		   	e.printStackTrace();
		}
		
		response.setCharacterEncoding("UTF-8");
		PrintWriter writer = response.getWriter();
		String jbString = new String(jb.toString().getBytes(),"UTF-8");
		writer.write(jbString);
		writer.flush();
		writer.close();
	}