Compile JSP tomcat JSTL error "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"
Problem:
Compile error from tomcat when it encounters a JSP: "According to TLD or attribute directive in tag file, attribute value does not accept any expressions"
Solution:
For some reason the JSP is using the 1.2 JSP (and 1.0 JSTL) and EL expressions aren't understood. There's a lot of hits on the web for this but in summary there are 2 important things to do to ensure you're getting the right version of the spec:
- Reference the correct servlet specification in your deployment descriptor:
<?xml version="1.0"?> <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
- Reference the correct JSTL uri in your JSP:
change<%@ taglib uri='http://java.sun.com/jstl/core' prefix='c'%>
to<%@ taglib uri='http://java.sun.com/jsp/jstl/core' prefix='c'%>
Notes:
What Specification goes with what? | |||
Web-app(deployment schema) | 2.3 | 2.4 | 2.5 |
http://java.sun.com/dtd/web-app_2_3.dtd | http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd | http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd | |
Servlet | 2.3 | 2.4 | 2.5 |
JSP | 1.2 | 2.0 | 2.1 |
JSTL(core uri reference) | 1.0 | 1.1 | 1.2 |
http://java.sun.com/jstl/core | http://java.sun.com/jsp/jstl/core | http://java.sun.com/jsp/jstl/core | |
Tomcat | 4.x | 5.x | 6.x |
WebSphere | 5.x | 6.x | 7.x (?) |