public void doPost(HttpServletRequest req,
			HttpServletResponse resp)
					throws ServletException, IOException {

		boolean exist = false;
		boolean isUser = false;
		String errorname= "";
		Listing pj= new Listing();
		DatastoreService dstore = DatastoreServiceFactory.getDatastoreService();

		/**
		 * Checking to see if the listing id already exists in the database
		 */
		Query q = new Query("Listid");
		PreparedQuery p = dstore.prepare(q);

		for (Entity e: p.asIterable()){
			if (e.getProperty("ListId").toString().equals(req.getParameter("id"))) {
				if(e.getProperty("user").toString().equals(req.getParameter("user"))){
					isUser = true;
					break;
				}
				else if (!e.getProperty("user").toString().equals(req.getParameter("user"))){
					errorname = "ListingID used";
					exist = true;
					break;
				}
			}
		}

		if(!exist || isUser){
			pj.setId((req.getParameter("id")));
			pj.setUser(req.getParameter("user"));
			pj.setOrigin(req.getParameter("origin"));
			pj.setDestination(req.getParameter("destination"));
			pj.setDate(req.getParameter("date"));
			pj.setTime(req.getParameter("time"));
			pj.setSeats(req.getParameter("seats"));
			pj.setCar(req.getParameter("car"));
			pj.setPrice(req.getParameter("price"));
			pj.setTransAuto(req.getParameter("transAuto"));
			pj.setTransMan(req.getParameter("transMan"));
			pj.setBags(req.getParameter("bags"));
			pj.setSharedDriving(req.getParameter("sharedDriving"));
			pj.setImage1(req.getParameter("image1"));
			pj.setImage2(req.getParameter("image2"));
			pj.setListingComment(req.getParameter("listcomment"));
			pj.upData();


			PrintWriter out = resp.getWriter();
			String title = "RegisterListing_response" ;
			out.println(

					"{"+  "\"" + title + "\"" +  ":   { \n" +

		  		    		   "\t"+  "\"" + "status" +"\"" + ":" +  "\"" + "successful		" +"\"" + "\n"  + 
		  		    		   "} }"

					);
		}
		else{
			PrintWriter out = resp.getWriter();
			String title = "RegisterListing_response" ;
			out.println(

					"{"+  "\"" + title +"\"" +  ":   { \n" +

		  		    		   "\t"+  "\"" + "status" +"\"" + ":" +  "\"" + "fail: " + errorname + " "  + "\"" + "\n"  + 
		  		    		   "} }"

					);
		}
	}