If I set session like this:
<%
session.setAttribute("taintedAttribute", "what ever we want");
%>
normally we can get session variable like this in EL
${sessionScope.taintedAttribute }
But how about if I want to do like this
<%
String name = "taintedAttribute";
//session.setAttribute(name, "what ever we want");
session.getAttribute(name);
%>
Then how can we call it in EL?
Can EL get something like ${sessionScope.---dynamic name ---}
?
If I do this:
<c:set var="name" value="taintedAttribute" />
<c:out value="${sessionScope.[name]}"/>
the name will be replaced by taintedAttribute
as the same as this line
${sessionScope.taintedAttribute}
Is that possible? How can I do that?
The client can create session attributes in a request by calling either the PostContent or the PostText operation with the sessionAttributes field set to a value. A Lambda function can create a session attribute in a response.
The session attribute indicates whether or not the JSP page uses HTTP sessions. A value of true means that the JSP page has access to a builtin session object and a value of false means that the JSP page cannot access the builtin session object.
<c:set var="name" value="taintedAttribute" />
<c:out value="${sessionScope.[name]}"/>
You were close. Remove the period.
<c:set var="name" value="taintedAttribute" />
<c:out value="${sessionScope[name]}"/>
Look at http://www.java2s.com/Code/Java/JSTL/JSTLSetVariablesScope.htm
<c:set var="test" value="Session Level Value"
scope="session" />
<c:out value="${sessionScope.test}" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With