Esempio n. 1
0
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    String forward = "";

    String action = request.getParameter("action");

    request.setAttribute("strLink", "config");

    String error = "sucess";

    request.setAttribute("action", action);
    if (action.equalsIgnoreCase("delete")) {

      int configId = Integer.parseInt(request.getParameter("configId"));

      dao.deleteConfig(configId);

      forward = LIST_CONFIG;

      request.setAttribute("configs", dao.getAllConfigs(""));

    } else if (action.equalsIgnoreCase("edit")) {

      forward = INSERT_OR_EDIT;

      int configId = Integer.parseInt(request.getParameter("configId"));

      Config config = dao.getConfigById(configId);

      request.setAttribute("config", config);

    } else if (action.equalsIgnoreCase("listConfig")) {

      forward = LIST_CONFIG;

      request.setAttribute("configs", dao.getAllConfigs(""));

    } else {

      forward = INSERT_OR_EDIT;
    }

    request.setAttribute("error", error);

    RequestDispatcher view = request.getRequestDispatcher(forward);

    view.forward(request, response);
  }