title: Pass value from jsp (java code> to javascript
body: <p>I have a jsp file called page.jsp, where I have the following code:</p>
  
  <pre><code>&lt;%@page import="soundcap.Soundcap"%&gt; 
  
  
  &lt;%
  Soundcap cfl = new Soundcap();
  String sfl = cfl.playFile();
  %&gt;
  </code></pre>
  
  <p>I need the value of sfl in a javascript file jscript.js</p>
  
  <p>Question:  How can I pass sfl from jsp and receive this value in javascript?</p>
  
  <p>I have tried &lt;%= sfl %> in javascript but didn't work.  I have set session in jsp (session.setAttribute("sfl",sfl) ) and tried to retrieve it in javascript (&lt;%= session('sfl'%>) but it didn't work.  Your help please.</p>