JSP exception, "quote symbol expected"
Solution 1
Don't use Java in JSPs, please. That's what the standard tag library is for.
<%@ 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>
In more detail:
- Embedding Java code in a JSP makes the page difficult to read (JSP is a tag-oriented language), difficult to maintain, and difficult to debug.
- The standard tag libraries are already debugged, have plentiful documentation and examples, and probably already Do What You Want To Do.
- If you truly have some logic that needs to be performed in Java and no pre-existing tags exist, you can either a) put the logic in a bean and call it via JSTL or b) write your own tag using tagfiles.
Why is Java code better in a bean or tag library than in a JSP?
- Testing is a big factor: beans and tag libraries can be tested outside of a running servlet environment with ease.
- Tag libraries are reusable and significantly cleaner than JSP includes.
Solution 2
Make sure all your quotes are straight quotes, not curvy ones.
Solution 3
I guess you have copy pasted it from somewhere, make sure the double quotes are proper. I had the same issue when I copied it from a PDF, it was resolved once I corrected my double quotes.
Solution 4
Your JSP works just fine with Tomcat 6. So, it's probably either some include-related issue or some previously compiled classes are not getting recompiled.
Try to clean up your Tomcat work directory and try again.
Solution 5
Check " if you copied it from somewhere. I had the same error because of ".
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> <%@page isELIgnored=”false” %>
double quotes around the false are the wrong ones. Change it to " and it will work.
Admin
Updated on July 15, 2020Comments
-
Admin almost 4 years
<%@ 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'm getting error
org.apache.jasper.JasperException: /result.jsp (line: 1, column: 18) quote symbol expected org.apache.jasper.compiler.DefaultErrorHandler.jspError(DefaultErrorHandler.java:42)
can't find any quotes that are not on right place.