protected void doPost(HttpServletRequest request, HttpServletResponse response) 
			throws ServletException, IOException {
		// TODO Auto-generated method stub
	try {  
              
            BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream(),"utf-8"));  
            String line = "";  
            StringBuffer buf = new StringBuffer();  
            while ( (line = br.readLine()) != null ) {  
                buf.append(line);  
            }
            br.close();
            JSONObject param = JSON.parseObject(buf.toString());
            //JSONObject param = new JSONObject(buf.toString());
            String email = param.getString("username");
            String password = param.getString("password");
            //String eMail = param.getString("email");
            JSONObject jb =new JSONObject();
            try{
            	connection = new Mongo();
            	scheduleDB = connection.getDB("schedule");
            	userCollection = scheduleDB.getCollection("user");
            	BasicDBObject loginQuery = new BasicDBObject();
                loginQuery.put("email", email);
                DBCursor cur = userCollection.find(loginQuery);
                if(!cur.hasNext()){
                	    jb.put("result", Primitive.USERUNREGISTERED);
                }else{
                	loginQuery.put("password", password);
                    cur = userCollection.find(loginQuery);
                    if(!cur.hasNext()){
                    	jb.put("result", Primitive.WRONGPASSWORD);
                    }else{
                    	DBObject result = cur.next();
                    	String userId = result.get("_id").toString();
                    	jb.put("result", Primitive.ACCEPT);
                    	jb.put("userId", userId);
                    }
                }
                
            }catch(MongoException e){
            	    jb.put("result", Primitive.DBCONNECTIONERROR);
            	    e.printStackTrace();
            }
        PrintWriter writer = response.getWriter();
    	writer.write(jb.toString());
    	writer.flush();
    	writer.close();
		}catch (IOException e) {  
            e.printStackTrace();  
        }
	
	}