protected void doGet(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		JSONObject jb = new JSONObject();
		String email = request.getParameter("email");
		String password = request.getParameter("password");
		String username = new String(request.getParameter("username").getBytes("ISO-8859-1"),"UTF-8");
		try{
			connection = new Mongo();
			scheduleDB = connection.getDB("schedule");
			userCollection = scheduleDB.getCollection("user");

			BasicDBObject registerQuery = new BasicDBObject();
			registerQuery.put("email", email);
			DBCursor cur = userCollection.find(registerQuery);
			if(cur.hasNext()){
				jb.put("result", Primitive.USERREGISTERED);
			}else{
				DBObject user = new BasicDBObject();
				
				user.put("email", email);
				user.put("password", password);
				user.put("username", username);
				user.put("image", "null");
				user.put("eventCount", 0);
				user.put("groupCount", 1);
				if(userCollection.save(user).getN() != 0){
					jb.put("result", Primitive.DBSTOREERROR);
				}else{
					jb.put("result", Primitive.ACCEPT);
					DBObject group = new BasicDBObject();
					//DBObject myself = new BasicDBObject();
					group.put("groupName","All friends");
					//myself.put("groupName","myself");
					DBCollection groupCollection = 
							scheduleDB.getCollection("group_" + user.get("_id"));
					groupCollection.save(group);
					//groupCollection.save(myself);
				}
			}
		}catch(MongoException e){
			jb.put("result", Primitive.DBCONNECTIONERROR);
		   	e.printStackTrace();
		}
		PrintWriter writer = response.getWriter();
		writer.write(jb.toString());
		writer.flush();
		writer.close();
	}