<%@page import="br.com.mercadohightech.entidade.Product" %>
<%@page import="java.util.List" %>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style>
@import 'https://fonts.googleapis.com/css?family=Open+Sans+Condensed:300';
</style>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Lista de Produtos</title>
</head>
<body>
<%
List<Product> products = (List<Product>) request.getAttribute("products");
%>
<h1 style="text-align:center;font-family: 'Open Sans Condensed', sans-serif;">Lista de produtos cadastrados</h1>
<table border="0" style="width: 70%; margin: auto; box-shadow: 0px 0px 20px black; border:none">
<thead style="background-color: #009cdf; color: white; border:none">
<th>Nome</th>
<th>Preço</th>
<th>Marca</th>
<th>Data de Validade</th>
</thead>
<tbody style="background-color: #7a7a7a; color: white; border:none">
<%for (Product product : products) {%>
<tr>
<td><%= product.getNome() %>
</td>
<td><%= product.getPrice() %>
</td>
<td><%= product.getBrand() %>
</td>
<td><%= product.getExpirationDate()%>
</td>
</tr>
<%}%>
</tbody>
</table>
</body>
</html>
erro:
HTTP Status 500 - An exception occurred processing JSP page /productlist.jsp at line 28
type Exception report
message An exception occurred processing JSP page /productlist.jsp at line 28
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: An exception occurred processing JSP page /productlist.jsp at line 28
25: <th>Data de Validade</th> 26: </thead> 27: <tbody style="background-color: #7a7a7a; color: white; border:none"> 28: <%for (Product product : products) {%> 29: <tr> 30: <td><%= product.getNome() %> 31: </td>
Stacktrace: org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:583) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:481) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) root cause
java.lang.NullPointerException org.apache.jsp.productlist_jsp._jspService(productlist_jsp.java:141) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:443) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:385) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:329) javax.servlet.http.HttpServlet.service(HttpServlet.java:729) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) note The full stack trace of the root cause is available in the Apache Tomcat/9.0.0.M8 logs.