protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		short idAdress = 0, idCompany, idCustomer= 0, idPerson, idReservation=0, idService = 0;
		short[] idGuests;
		short guests;
		
		String guestOption;
		String option;
		
		AdressManagerImpl adressMan = new AdressManagerImpl();
		PersonManagerImpl personMan = new PersonManagerImpl();
		ReservationIncludingPersonManagerImpl ripMan = new ReservationIncludingPersonManagerImpl();
		ReservationManagerImpl reservationMan = new ReservationManagerImpl();
		CompanyManagerImpl companyMan = null;
		ServiceManagerImpl serviceMan = null;
		
		Adress adress = new Adress(request.getParameter("country"), request.getParameter("city"), request.getParameter("street"), request.getParameter("number"), request.getParameter("tel"), request.getParameter("email"));
		ReservationIncludingPerson rip = null;
		Company company = null;
		Reservation reservation = null;
		
		List<Service> services = new ArrayList<Service>();
		
		
		option = request.getParameter("next");
		if(option.equals("Dalej")) {
		
			try {
				//person.setName(null);
				idAdress = adressMan.save(adress);
				
				Person person = new Person(idAdress, request.getParameter("pesel"), request.getParameter("surname"), request.getParameter("name"));
				//Person person = new Person(idAdress, String.valueOf(request.getSession().getAttribute("spesel")), String.valueOf(request.getSession().getAttribute("ssurname")), String.valueOf(request.getSession().getAttribute("sname")));
				idPerson = personMan.save(person);
				
				if(request.getParameter("company") != "") {
					
					company = new Company(idPerson, request.getParameter("company"));
					companyMan = new CompanyManagerImpl();
					companyMan.save(company);
				}
				
				
				
				//System.out.println(idCustomer);
				//reservation = new Reservation(Short.parseShort(request.getParameter("idRoom")), idPerson, Date.valueOf(request.getParameter("dateFrom")), Date.valueOf(request.getParameter("dateTo")));
				reservation = new Reservation(Short.parseShort(String.valueOf(request.getSession().getAttribute("idRoom"))), idPerson, Date.valueOf(String.valueOf(request.getSession().getAttribute("dateFrom"))), Date.valueOf(String.valueOf(request.getSession().getAttribute("dateTo"))));
				idReservation = reservationMan.save(reservation);
				
				/*********** Adding other person to reservation *************************/
			
				guests = Short.parseShort(String.valueOf(request.getSession().getAttribute("person")));
				guestOption = request.getParameter("guest");
				if(guests > 1 && guestOption.equals("tak")){
					//rip = new ReservationIncludingPerson(idReservation, idPerson);
					//ripMan.save(rip);
					String[] names = request.getParameterValues("guests.name");
					String[] surnames = request.getParameterValues("guests.surname");
					idGuests = new short[guests];
					
					for(int i=0; i< guests-1; i++) {
						Person guest = new Person(surnames[i], names[i]);
						idGuests[i] = personMan.save(guest);
						rip = new ReservationIncludingPerson(idReservation, idGuests[i]);
						ripMan.save(rip);
					}
				}
				
				request.getSession().setAttribute("reservation", idReservation);
				//request.getRequestDispatcher("/WEB-INF/services.jsp").forward(request, response);
				response.sendRedirect("services.jsp");
				
				//System.out.println(request.getParameter("idRoom")+request.getParameter("dateFrom")+request.getParameter("dateTo")+"asdasf");
				//System.out.println("Id dodanego adresu: "+id);
			} catch(HibernateException ex) {
				System.out.println("Error. "+ex);
			}
		
		}
		else {
			/*********** Adding some Services ***************************************/
			//System.out.println("asdasdadadads");
			serviceMan = new ServiceManagerImpl();
			try{
				services = (List<Service>) request.getAttribute("services");
			} catch(Exception ex) {
				return;
			}
			idReservation = Short.valueOf(String.valueOf(request.getSession().getAttribute("reservation")));
			/*System.out.println(services.size());
			System.out.println(services.get(0).getType());
			System.out.println(services.get(1).getType());
			System.out.println(String.valueOf(request.getSession().getAttribute("idRoom")));
			System.out.println(String.valueOf(request.getSession().getAttribute("person")));*/
			//System.out.println(services.size());
			if(services.size() > 0) {
				for(int i=0; i<services.size(); i++) {
					services.get(i).setIdReservation(idReservation);
					serviceMan.save(services.get(i));
				}
			}
			
			response.sendRedirect("searchreservation.jsp");
			
		}
	}