@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		
		HttpSession session = req.getSession();
		if(session.getAttribute("id") != null){
			//User is logged in
			//Get datastore service
			com.google.appengine.api.datastore.DatastoreService ds = DatastoreServiceFactory.getDatastoreService();
			Entity e;
			try {
				//Entity e is current logged in user
				e = ds.get(new Entity("User", (String)session.getAttribute("email")).getKey());
				//Request attribute to hold user information
				req.setAttribute("user", getUser(e));

				System.out.println("ProfileServlet: Sending '" + (String)session.getAttribute("email")+"profilePicture" + "'");
				Image image = getImage((String)session.getAttribute("email")+"profilePicture");
				if(image != null && image.getImageType() != null && image.getImage() != null){
					System.out.println("ProfileServlet: valid image");
					resp.setContentType(image.getImageType());
					resp.getOutputStream().write(image.getImage());
				}
				System.out.println("ProfileServlet: not valid image");
			} catch (EntityNotFoundException e1) {
				e1.printStackTrace();
			}
			req.getRequestDispatcher("/WEB-INF/myprofile-main.jsp").forward(req, resp);
		}else{
			req.getRequestDispatcher("/WEB-INF/index.jsp").forward(req, resp);
		}
	}