${variable} not working
Okay, it's been a while since I've done any JSPs, and something simple has obviously slipped my mind. I'm trying to do some comparisons of different presentation tiers for a new project. This is a Struts2 version.
This code:
<c:forEach var="i" begin="1" end="10">
${i},
</c:forEach>
generates this result:
${i}, ${i}, ${i}, ${i}, ${i}, ${i}, ${i}, ${i}, ${i}, ${i},
I get the same thing if I do this instead:
<c:forEach var="i" begin="1" end="10">
<c:out value="${i}"/>,
</c:forEach>
So I know that JSTL is loading properly, as the forEach is working. The problem is interpreting the "${i}". This was not the original problem, of course. I was trying to get at a variable in request scope. It worked in a scriptlet, but not when I try to reference it through the ${} notation.
Any suggestions?
# 2
> put the page directive <%@ page isELIgnored="false"
> %> at the top of your jsp
Thank you. That did it. Is there some place I can configure this so that I don't need it on each page? I'm new to Struts2/WebWork, and am assuming that they must somewhere override the default behavior which wouldn't ignore the EL. Or am I just confused?
Thanks,
-- Scott
# 3
Yes there is.
Its all detailed in [url http://forum.java.sun.com/thread.jspa?threadID=629437&tstart=0] this post reply#6[/url]
Basically you need to upgrade your web.xml to state that it is version 2.4
If web.xml states that it is version 2.3 or less, then EL evaluation is disabled by default for backwards compatibility.
If your web.xml starts with this:<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
<web-app>
Replace it with this
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app 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"
version="2.4">
cheers,
evnafets