1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| @WebServlet(name = "ProductServlet", urlPatterns = "/products") public class ProductServlet extends HttpServlet { @Override protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { ProductDao productDao = new ProductDaoImpl(); try { List<Product> products = productDao.selectAll(); System.out.println(products); request.getSession().setAttribute("products", products); } catch (SQLException e) { e.printStackTrace(); } }
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { doPost(request, response); } }
|