title: jsp set variable variable name
body: <p>I have been looking how to do this properly but cannot find a definitive guide on how to do with.</p>
  
  <p>I know that you cannot use an expression within the  tag, but I am unsure how else I am meant to approach it.</p>
  
  <p>I've seen a multitude of answers for this without much explanation or help.</p>
  
  <p>Essentially I want something like the following to work, but obviously doesn't.</p>
  
  <pre><code>&lt;c:forEach items="${dataposition.rows}" var="lineposition" begin="0" varStatus="status"&gt;
      &lt;c:set var="name_${status.count}" value="${lineposition.value}" scope="session"/&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>The exact error message is </p>
  
  <blockquote>
    <p>"According to TLD or attribute durective in tag file, attribute var
    does not accept any expressions"</p>
  </blockquote>
  
  <p>What is the proper way to accomplish this?</p>
  
  <p>(I changed the variable names from my actual code, but hopefully you still get the idea)</p>
  
  <p>If I need to create java objects or something I am fine with that, but I would need to know how to include them in my project and how to use them within the code. Something like a list sounds about right.</p>
  
  <p>I have created an object to hold my values for me.</p>
  
  <pre><code>&lt;jsp:useBean id="myid" class="myclass" scope="session"/&gt;
  </code></pre>
  
  <p>and I want to use it, but am unsure how:</p>
  
  <pre><code>&lt;c:forEach items="${dataposition.rows}" var="lineposition" begin="0" varStatus="status"&gt;
      &lt;%
          myid.add_position(lineposition.var1, lineposition.var2, lineposition.var3, lineposition.var4, lineposition.var5);
      %&gt;
  &lt;/c:forEach&gt;
  </code></pre>