blablalblalblab

<% List styl...">

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.

+5
source share
5 answers

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.
+5

, , .

+5

, -, , . , PDF-, , .

+2

JSP Tomcat 6. , , , .

Tomcat .

+1

JSTL , Java JSP, . .

, . - . - h1, :
< h1 align = center >
, . < h1 align = "center" >

, , , , .

-, it.next()? , , , - , , .

-, Pradeep- , , - , , stackoverflow. , " " IE, ( Outlook ) . IE

'

`

.

0
source

All Articles