-
JSTL c:set problem
So for some reason when I set variables they just... don't exist O.o
Some test code I wrote:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix = "c"%>
<c:set var="period" value="1" scope="session" />
<c:out value="${param.period}" />
This just shows a blank page. I was using something similar in different code earlier and at one point I printed the variable, which worked, but now it won't print anything anymore, and when I use it in a constraint I get incorrect results. I can't see any syntax errors. Anybody know whats going on?
-
Look like the uri value does not return xml file anymore.
I think it is better for you to create one jstl xml file.
-
Thanks! Can you elaborate on how to do that?
-
Still confused, any more help would be great...
-
Have a read here.
The URI is dependent on the version of the library you are using (see link).
It's a marker, not a real location, used by the library.
-
Thanks for that Tolls. I'm not sure if that's the problem though, since my jstl sql statements are working fine.
Also I added the following line to my code and it outputted 5 like it should:
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix = "c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix = "sql"%>
<c:set var="period" value="1" scope="session" />
<c:out value="${param.period}" />
<c:out value="${3+2}" />
Then again I could have just misunderstood the link you sent me >.>
-
Actually, is that first c:out correct?
You've just stored "period" in your session.
Shouldn't that be "sessionScope.period" then?
-
Also, as the link I posted says, you don't need to use c:out for EL.
The EL will be translated anyway.
-
Oh... that worked! Apparently I need to brush up on my syntax >.>
Thanks!
-
I should have spotted that sooner.
I got distracted by jing-yi's point, which turned out to be a wrong turn...:)
-
Heh, I probably should have spotted it myself. ^_^ Thanks again