0

How can I print my servlet data to my jsp table

I am new to dynamic coding and I was wondering if anyone here could help me with putting my data from my dao in the servlet to the table in the jsp. Any help would be very appreciated public class Snippet { <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@page import="DAO.MembersDAO"%> <%@page import="DTO.Member"%> <%@page import="DAO.ItemDAO"%> <%@page import="DTO.Item"%> <%@page import="DAO.BuyDAO"%> <%@page import="DTO.Buy"%> <%@page import="DAO.Buy_detailDAO"%> <%@page import="DTO.Buy_detail"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <link rel="stylesheet" type="text/css" href="./css/common.css"> <link rel="stylesheet" type="text/css" href="./css/order.css"> <link rel="stylesheet" type="text/css" href="./css/button.css"> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous"> <title>????????</title> </head> <body> <%-- jsp:include page="Header.jsp" flush="true"></jsp:include>--%> if(request.getAttribute"memberHistory" != null) <br> <center><h1>????????</h1></center> <br> <table class="table table-bordered table-hover"> <tr> <th width="3%"><center>BuyDate</center></th>//By day <th width="5%"><center>BuyNumber</center></th> //Bynumber <th width="10%"><center>ItemPicturer</center></th>//item picture <th width="5%"><center>ItemName</center></th>//item name <th width="5%"><center>SumPrice</center> </th>//sumprice <th width="3%"><center>Status</center></th>//status <th width="3%"><center> </center></th>//each data </tr></table> <table class="table table-bordered table-hover"> <tr> <th width="3%" ><center><% )%><

25th Jun 2019, 7:45 PM
Reuinte' Howard
1 Respuesta
0
import java.io.IOException; import java.sql.SQLException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import DAO.BuyDAO; import DAO.Buy_detailDAO; import DAO.ItemDAO; import DAO.MembersDAO; import DTO.Buy; import DTO.Buy_detail; import DTO.Item; @WebServlet("/memberOrderHistory") public class memberOrderHistory extends HttpServlet { private static final long serialVersionUID = 1L; protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8"); Buy_detailDAO buy_detailDAO = new Buy_detailDAO(); try { MembersDAO membersdao =new MembersDAO(); HttpSession session = request.getSession(); String id=(String)session.getAttribute("id"); BuyDAO buydao=new BuyDAO(); List <Buy> list = buydao.selectALLbyid(id); Buy_detailDAO buy_detaildao = new Buy_detailDAO(); List<Buy_detail>buy_detaillist = null; for (Buy b : list) { buy_detaillist = buy_detaildao.selectALLbybuy_number(b.getBuy_number()); } Item item = null; for (Buy_detail d : buy_detaillist) { ItemDAO itemdao = new ItemDAO(); item=itemdao.selectbyID(d.getItem_id()); } item.getItem_picture(); item.getItem_name(); item.getItem_price(); response.sendRedirect("orderhis_011.jsp"); } catch (IllegalStateException e) { // TODO ??????? catch ???? e.printStackTrace(); } catch (SQLException e) { // TODO ??????? catch ???? e.printStackTrace(); } } private Buy_detail buy_detailDAO() { // TODO ??????????????? return null; } protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub doGet
25th Jun 2019, 7:45 PM
Reuinte' Howard