Reputation: 2264
I am trying to use JSTL for my index.jsp page, but for some reason each time after packaging project to .war and running with Tomcat it gives me following errors:
HTTP Status 500 - /index.jsp (line: 12, column: 0) Unterminated <c:if tag
or
HTTP Status 500 - java.lang.ClassNotFoundException: org.apache.jsp.index_jsp
From what I found on google, there are 2 ways to install JSTL into your Maven project: 1) Add this to pom.xml
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
2) Add some jars to WEB-INF/lib, but here's the problem: no such folder was automaticaly created and if I do it manually it does not help. Project structure looks like this:
The code of index.jsp is the following:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
<p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>
So, what should I do to make those work? I can't find any guide or piece of information that could help me solving this. Thanks for having a look at my problem!
Upvotes: 0
Views: 1785
Reputation: 6434
Just what compiler tells you: Unterminated c:if tag:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
<p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>
Look at line 4 of your jsp:
<title><c:if> Tag Example</title>
It must be
<title><c:if> Tag Example </c:if></title>
EDIT: As seems that I explained badly, I have tested in a running web-app, and this way (that is just what I was trying to explain) works:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<title><c:if> Tag Example</title>
</head>
<body>
<c:set var="salary" scope="session" value="${2000*2}"/>
<c:if test="${salary > 2000}">
<p>My salary is: <c:out value="${salary}"/><p>
</c:if>
</body>
</html>
Upvotes: 1