Servlet takes the value and passes it to jsp, but the output is null. What went wrong?

jsp"s mall system, after the background servlet takes the commodity data of the database, it is forwarded to jsp to render, but the foreground rendering is always blank. After looking for it for a long time, it does not find a problem and does not report an error. Here is the code:

ListProductServlet.java

package sh.shop.web.servlet.manager;
import java.io.IOException;
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 sh.shop.domain.Product;
import sh.shop.exception.ListProductException;
import sh.shop.service.ProductService;

@WebServlet("/listProduct")
/**
 * 
 * servlet
 */
public class ListProductServlet extends HttpServlet {
    public void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
            try {
                // 1.service
                ProductService service = new ProductService();
                // 2.servicelistAll()
                List<Product> list = service.listAll();
                // 3.request
                request.setAttribute("list", list);
                // 4.list.jsp
                request.getRequestDispatcher("/admin/products/list.jsp").forward(
                                request, response);
                return;
            } catch (ListProductException e) {
                    e.printStackTrace();
                    response.getWriter().write(e.getMessage());
                    return;
            }
    }
    public void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        doGet(request,response);
    }
}

ProductService.java

package sh.shop.service;

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 sh.shop.exception.AddProductException;
import sh.shop.dao.ProductDao;
import sh.shop.domain.Product;
import sh.shop.exception.ListProductException;


@WebServlet("/ProductService")
public class ProductService {
    private ProductDao dao = new ProductDao();

    public List<Product> listAll() throws ListProductException {
        try {
            List<Product> list = dao.listAll();
            return list;
        } catch (SQLException e) {
            e.printStackTrace();
            throw new ListProductException("");
        }
    }
    
    public void addProduct(Product p) throws AddProductException {
        try {
            dao.addProduct(p);
        } catch (SQLException e) {
            e.printStackTrace();
            throw new AddProductException("");
        }
    }
    
}

ProductDao.java

package sh.shop.dao;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.ArrayListHandler;
import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import org.apache.commons.dbutils.handlers.ScalarHandler;
import sh.shop.domain.Product;
import sh.shop.utils.DataSourceUtils;

public class ProductDao {
    // 
    public List<Product> listAll() throws SQLException {
        String sql = "select * from products";
        QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
        List<Product> list = runner.query(sql, new BeanListHandler<Product>(Product.class));
        return list;
    }
    
    //
    public void addProduct(Product p) throws SQLException {

        String sql = "insert into products values(?,?,?,?,?,?,?)";
        QueryRunner runner = new QueryRunner(DataSourceUtils.getDataSource());
        runner.update(sql, p.getId(), p.getName(), p.getPrice(),
                null, p.getImgurl(), p.getDescription());
    }
}

list.jsp

<tbody>
<c:forEach items="${list}" var="p">
    <tr class="text-c va-m">
        <td><input name="" type="checkbox" value=""></td>
        <td>${p.id }</td>
        <td><a onClick="" href="javascript:;"><img width="60" class="product-thumb" src=""></a></td>
        <td class="text-l"><a style="text-decoration:none" onClick="" href="javascript:;">${p.name }</a></td>
        <td class="text-l">${p.description }</td>
        <td>${p.price }</td>
        <td>${p.category }</td>
        <td class="td-manage"><a style="text-decoration:none" class="ml-5" onClick="product_edit("","product-add.html","10001")" href="javascript:;" title=""><i class="Hui-iconfont"></i></a> <a style="text-decoration:none" class="ml-5" onClick="product_del(this,"10001")" href="javascript:;" title=""><i class="Hui-iconfont"></i></a></td>
    </tr>
</c:forEach>
</tbody>

clipboard.png

:

Oct.03,2021

look at the list in the front-end value stack with the debug tag. Null is the problem of passing values, otherwise it is the problem of selecting values at the front end


@ Master Bird is that it? I don't understand.
clipboard.png


${requestScope.list} give it a try? The first floor means to have a look at the browser debug.


put the session bar cycle length

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e8163f-b51.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e8163f-b51.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?