protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException 
	{
		loggedInUser = (User) request.getSession().getAttribute("user");
		
		//Check is user is logged in for session
		if (loggedInUser == null)
		{
			response.sendRedirect(request.getContextPath() + "/login");	//Not logged in yet - redirect to login page
			return;
		}
		else
		{
			if (request.getRequestURI().equals(request.getContextPath() + "/profile"))
			{
				
				//Show logged in user's profile
			
				request.getSession().setAttribute("following", countFollowing(loggedInUser));
				request.getSession().setAttribute("followers", countFollowers(loggedInUser));
				request.getSession().setAttribute("userMessages", getAllMessages(loggedInUser));
				request.getRequestDispatcher("profile.jsp").forward(request, response);	//View from corresponding profile.jsp
				return;
			}
			else
			{
				//Show specific user's profile specified in URI - /profile/<userEmail>
				
				int lastSeparator = request.getRequestURI().lastIndexOf('/');
				String uriString = request.getRequestURI().substring(lastSeparator + 1);
				
				
				otherUser = userService.getProfileUser(uriString);
				//Check to display 404
				if (otherUser == null)
				{
					request.getRequestDispatcher("../404.jsp").forward(request, response);
					return;
				}

				request.setAttribute("user", otherUser);
				request.setAttribute("otherUser", true);	//To differentiate between logged-in (Session) user and one we're viewing (Page)
				request.setAttribute("following", countFollowing(otherUser));
				request.setAttribute("followers", countFollowers(otherUser));
				request.setAttribute("userMessages", getUserMessages(otherUser));//Only view the user's messages, not their friends' etc.
				request.getRequestDispatcher("../profile.jsp").forward(request, response);	//View from corresponding profile.jsp
				return;

			}
		}
	}