protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException 
	{
		MessageManager mm = new MessageManager(ds);
		ArrayList<MessageDetails> messages;
		
		String path = req.getRequestURI();
		String[] pathComponents = path.split("/");
		StringBuffer jsonBuffer = new StringBuffer();
		String finalJson = new String();
		boolean success = false;
		
		if(pathComponents.length < 3)
		{
			resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
			return;
		}
		
		if(!pathComponents[2].equals("message"))
		{
			resp.setStatus(HttpServletResponse.SC_BAD_REQUEST);
			return;
		}
		
		/* Convert list to json and then return to the view so it can be rendered.
		 * 
		 */
		if(pathComponents[3].equals("getAllMessages"))
		{
			//
			// Iterate through the ArrayList and produce a series of JSON objects.
			//
			
			messages = mm.fetchAllMessages();
			
			if(messages.size() != 0)
			{	
				jsonBuffer.append(ListTransformer.returnMessagesFromArrayList(messages));
				
				finalJson = jsonBuffer.toString();
				
				PrintWriter output = resp.getWriter();
				
				resp.setContentType("application/json");
				resp.setStatus(HttpServletResponse.SC_OK);
				output.write(finalJson);
				return;
				
			}else
			{
				resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
				resp.setContentType("text/plain");
				resp.setContentLength(0);
				return;
			}			
		}
		
		if(pathComponents[3].equals("findMessageByID"))
		{
			int messageid = Integer.valueOf(pathComponents[4]);
			
			messages = mm.fetchMessageById(messageid);
			
			if(messages.size() !=0)
			{
				jsonBuffer.append(ListTransformer.returnMessagesFromArrayList(messages));
				
				finalJson = jsonBuffer.toString();
				
				PrintWriter output = resp.getWriter();
				
				resp.setContentType("application/json");
				resp.setStatus(HttpServletResponse.SC_OK);
				output.write(finalJson);
				return;
			}else
			{
				resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
				resp.setContentType("text/plain");
				resp.setContentLength(0);
				return;
			}
		}
		
		if(pathComponents[3].equals("findMessagesByUsername"))
		{
			String userName = pathComponents[4];
			
			messages = mm.fetchMessagesByUserName(userName);
			
			if(messages.size() !=0)
			{
				jsonBuffer.append(ListTransformer.returnMessagesFromArrayList(messages));
				
				finalJson = jsonBuffer.toString();
				
				PrintWriter output = resp.getWriter();
				
				resp.setContentType("application/json");
				resp.setStatus(HttpServletResponse.SC_OK);
				output.write(finalJson);
				return;
			}else
			{
				resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
				resp.setContentType("test/plain");
				resp.setContentLength(0);
				return;
			}
		}
		
		if(success == false)
		{
			resp.setStatus(HttpServletResponse.SC_NOT_FOUND);
			resp.setContentType("test/plain");
			resp.setContentLength(0);
		}
	}