protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    String forward = "";
    String action = request.getParameter("action");

    if (action.equalsIgnoreCase("delete")) {
      long recipeIngredientID = Long.parseLong(request.getParameter("id_przepis_skladnik"));
      dao.deleteRecipeIngredient(recipeIngredientID);
      forward = LIST_RECIPE_INGREDIENTS;
      request.setAttribute("RecipeToIngredient", dao.getAllRecipeIngredients());
    } else if (action.equalsIgnoreCase("edit")) {
      forward = INSERT_OR_EDIT;
      long recipeIngredientID = Long.parseLong(request.getParameter("id_przepis_skladnik"));
      RecipeToIngredient recipeIngredient = dao.getRecipeIngredientById(recipeIngredientID);
      request.setAttribute("RecipeToIngredient", recipeIngredient);
    } else if (action.equalsIgnoreCase("listRecipesIngredients")) {
      forward = LIST_RECIPE_INGREDIENTS;
      request.setAttribute("RecipeToIngredient", dao.getAllRecipeIngredients());
    } else {
      forward = INSERT_OR_EDIT;
    }

    RequestDispatcher view = request.getRequestDispatcher(forward);
    view.forward(request, response);
  }
  protected void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    RecipeToIngredient recipeIngredient = new RecipeToIngredient();
    recipeIngredient.setId_przepis(Integer.parseInt(request.getParameter("id_przepis")));
    recipeIngredient.setId_skladnik(Integer.parseInt(request.getParameter("id_skladnik")));
    recipeIngredient.setIlosc(Integer.parseInt(request.getParameter("ilosc")));
    String recipeIngredientId = request.getParameter("id_przepis_skladnik");
    if (recipeIngredientId == null || recipeIngredientId.isEmpty()) {
      dao.addRecipeIngredient(recipeIngredient);
    } else {
      recipeIngredient.setId_przepis_skladnik(Long.parseLong(recipeIngredientId));
      dao.updateRecipeIngredient(recipeIngredient);
    }

    RequestDispatcher view = request.getRequestDispatcher(LIST_RECIPE_INGREDIENTS);
    request.setAttribute("RecipeToIngredient", dao.getAllRecipeIngredients());
    view.forward(request, response);
  }