From e000fc56a5c904691378b4d6a3508f9b27a5ed22 Mon Sep 17 00:00:00 2001 From: Yuht Date: Wed, 6 Mar 2024 23:51:03 +0700 Subject: [PATCH 1/2] =?UTF-8?q?Th=C3=BAy-=20fix=20bug=20154=20(Completed)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../management/customer/CustomerServlet.java | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java b/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java index c710879..511edd9 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java @@ -21,9 +21,18 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) int pageSize = 10; // Get the requested page number - String pageStr = request.getParameter("page"); - if (pageStr != null) { - pageNumber = Integer.parseInt(pageStr); +// String pageStr = request.getParameter("page"); +// if (pageStr != null) { +// pageNumber = Integer.parseInt(pageStr); +// } + + if (request.getParameter("page") != null) { + try { + pageNumber = Integer.parseInt(request.getParameter("page")); + } catch (Exception e) { + response.sendRedirect("./error-404"); + return; + } } List customers = Singleton.customerDAO.pagination((pageNumber - 1) * pageSize, pageSize); @@ -38,7 +47,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) request.setAttribute("totalPages", totalPages); request.setAttribute("pageSize", pageSize); request.setAttribute("page", "customer"); - request.getRequestDispatcher("/view/jsp/management/customer/customer.jsp").forward(request, response); } From 26e70c4e9650477bc8476bd4f859bc35abe09027 Mon Sep 17 00:00:00 2001 From: Yuht Date: Thu, 7 Mar 2024 09:38:15 +0700 Subject: [PATCH 2/2] Update CustomerServlet.java --- .../controller/management/customer/CustomerServlet.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java b/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java index 511edd9..0ba36b6 100644 --- a/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java +++ b/src/main/java/io/hardingadonis/saledock/controller/management/customer/CustomerServlet.java @@ -20,12 +20,6 @@ protected void doGet(HttpServletRequest request, HttpServletResponse response) int pageNumber = 1; int pageSize = 10; - // Get the requested page number -// String pageStr = request.getParameter("page"); -// if (pageStr != null) { -// pageNumber = Integer.parseInt(pageStr); -// } - if (request.getParameter("page") != null) { try { pageNumber = Integer.parseInt(request.getParameter("page"));