title: How to pass a param tag dynamically to JSTL query?
body: <p>I'm using the JSTL query tag to do the mysql query as following:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;sql:query var="altTime" dataSource="${dataSource}" scope="request"&gt;
       SELECT distinct combined.alt_tm FROM (
        SELECT distinct sal_tm as alt_tm FROM sales WHERE sal_snum=? AND sal_dt=? AND sal_trn=? AND sal_trm=?
        UNION ALL
        SELECT distinct tm_cr as alt_tm FROM credit WHERE stc_cr=? AND ym_cr=? AND trn_cr=? AND trm_cr=?
        UNION ALL
        SELECT distinct tm_nm as alt_tm FROM nmc WHERE stc_nm=? AND ym_nm=? AND trn_nm=? AND trm_nm=?
        UNION ALL
        SELECT distinct tm_gc as alt_tm FROM gift WHERE stc_gc=? AND ym_gc=? AND trn_gc=? AND trm_gc=?
       ) AS combined WHERE alt_tm != '00:00:00' LIMIT 1
       &lt;sql:param value="${store}"/&gt;
       &lt;sql:param value="${date}"/&gt;
       &lt;sql:param value="${trans_no}"/&gt;
       &lt;sql:param value="${terminal}"/&gt;
       &lt;sql:param value="${store}"/&gt;
       &lt;sql:param value="${date}"/&gt;
       &lt;sql:param value="${trans_no}"/&gt;
       &lt;sql:param value="${terminal}"/&gt;
       &lt;sql:param value="${store}"/&gt;
       &lt;sql:param value="${date}"/&gt;
       &lt;sql:param value="${trans_no}"/&gt;
       &lt;sql:param value="${terminal}"/&gt;
       &lt;sql:param value="${store}"/&gt;
       &lt;sql:param value="${date}"/&gt;
       &lt;sql:param value="${trans_no}"/&gt;
       &lt;sql:param value="${terminal}"/&gt;
   &lt;/sql:query&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>It works and now I'm trying to set the params dynamically by create it as a string and then put it into the tag. Change the last param tag to a string and test.
  In script</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>String test="&lt;sql:param value=\"${terminal}\"/&gt;";</code></pre>
  </div>
  </div>
  </p>
  
  <p>In query tag, use the string as the last line</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;%=test %&gt;</code></pre>
  </div>
  </div>
  </p>
  
  <p>But this fail while running. Error message: " No value specified for parameter 16"My guess is that it's parsed as a string and didn't run as a normal param. Any ideas that I can avoid this?
  Detail error messages below, it shows the last string which it shouldn't (should be parsed as a jtsl tag)</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Exception handling request to /kwi_demo/generic2/ecd/ecd1.jsp: org.apache.jasper.JasperException: javax.servlet.ServletException: javax.servlet.jsp.JspException:
                                          SELECT distinct combined.alt_tm FROM (
                                                  SELECT distinct sal_tm as alt_tm FROM sales WHERE sal_snum=? AND sal_dt=? AND sal_trn=? AND sal_trm=?
                                                  UNION ALL
                                                  SELECT distinct tm_cr as alt_tm FROM credit WHERE stc_cr=? AND ym_cr=? AND trn_cr=? AND trm_cr=?
                                                  UNION ALL
                                                  SELECT distinct tm_nm as alt_tm FROM nmc WHERE stc_nm=? AND ym_nm=? AND trn_nm=? AND trm_nm=?
                                                  UNION ALL
                                                  SELECT distinct tm_gc as alt_tm FROM gift WHERE stc_gc=? AND ym_gc=? AND trn_gc=? AND trm_gc=?
                                          ) AS combined WHERE alt_tm != '00:00:00' LIMIT 1
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
                                          &lt;sql:param value=${terminal}/&gt;
                                  : No value specified for parameter 16</code></pre>
  </div>
  </div>
  </p>