title: How can I create dynamic variable names in JSTL or an alternative
body: <p>I need to use JSTL and ideally I think an Array would be better as I need to create a bunch of variables with a value using SQL data from data.rows but I need to get the variable name from the data using row.type. However I am finding this hard because you cannot define a session variable using "${row.type}" as it raises an exception. It must be a concrete variable name. I would have thought an array would be best but no idea how to do this from my SQL JSTL query:</p>
  
  <pre><code>&lt;sql:query var="data"&gt;
      SELECT type, balance FROM Account WHERE account_number IN (SELECT account_number FROM CustomerAccount WHERE customer_number = "${sessionScope.CustomerNumber}");
  &lt;/sql:query&gt;
  </code></pre>
  
  <p>This is the code:</p>
  
  <pre><code>&lt;c:forEach var="row" items="${data.rows}"&gt;
      &lt;c:set var="${row.type}" value="${row.balance}" scope="session" /&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>Any help or tips would be brilliant! Thank you.</p>