JSP exception, "quote symbol expected"
<%@ page import="java.util.*" %>
<html>
<body>
<h1 align="center">blablalblalblab</h1>
<p>
<%
List styles = (List)request.getAttribute("styles");
Iterator it = styles.iterator();
while(it.hasNext()) {
out.print("<br>try: " + it.next());
}
%>
</p>
</body>
</html>
after executing my servlet request, I get an error
org.apache.jasper.JasperException: /result.jsp (row: 1, column: 18) org.apache.jasper.compiler.DefaultErrorHandler.jspError (DefaultErrorHandler.java:42)
cannot find quotes that are not in the right place.
Do not use Java in JSP, please. This is what is for the standard tag library.
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<body>
<h1 align="center">blablalblalblab</h1>
<p>
<c:forEach items="${styles}" var="style">
<br>try: ${style}
</c:forEach>
</p>
</body>
</html>
More details:
- Embedding Java code in the JSP makes the page difficult to read (JSP is a tag-oriented language), which is difficult to maintain and difficult to debug.
- , , , , .
- - , Java, , : a) bean JSTL b) , .
Java bean , JSP?
- - : beans .
- , JSP.