The problem i am having is like this there is variable
<core:set var="type">*one of: load,migrate, or ...* </core:set>
and the value of load, migrate, is a map. Now, i want to print the value of these based on the type? Is it possible at all?
The problem i am having is like this there is variable
<core:set var="type">*one of: load,migrate, or ...* </core:set>
and the value of load, migrate, is a map. Now, i want to print the value of these based on the type? Is it possible at all?
if they are not in a map, its hard.
I assume you wanted to do it the way perl works: where you could type
$foo = "stuff";
$varName = "foo";
print $$varName; #prints "stuff"
That doesnt work in jsp.
If its a map,you can do ${mapValue[key]}
. Info on this page near the Variables section
This will achieve the same effect as @Chii's answer:
<c:set var="attributeName" value="foo"/>
<%
out.println(pageContext.getAttribute(attributeName) + " = " + pageContext.getAttribute(pageContext.getAttribute(attributeName)));
%>
This, nasty as it is, will list all the attributes in the page scope if you need to do that:
<%
for (String attributeName : pageContext.getAttributeNamesInScope(PageContext.PAGE_SCOPE))
{
out.println(attributeName + " = " + pageContext.getAttribute(attributeName));
}
%>
Don't think there's a way to do this in JSTL, but you normally only need this during debugging so I don't have such a problem with the scriptlet code.