Avatar ·

How to avoid Java code in JSP files when using JSP 2 (Servlet 2.4)?

Hello everyone! I'm a beginner Java developer, and I have a problem with the architecture of my web application. I'm writing a simple online store using Java EE, using JSP for displaying pages. The problem is that my JSP files have turned into "spaghetti code" of HTML and Java scriptlets. Here's what my typical JSP file for displaying a product list looks like: ```jsp <%@ page import="java.util.List, com.myapp.Product" %>

Products

<% List products = (List) request.getAttribute("products"); for (Product p : products) { %> <% } %>
<%= p.getName() %> <%= p.getPrice() %> Buy
``` I've heard that