title: How to pass java string variable to the javascript function by jsp expression tag?
body: <p>I want to passing a java String variable to the javascript function parameter using jsp expression tag.Below is my jsp page.</p>
  
  <p><strong>First.jsp</strong></p>
  
  
  
  <pre><code>&lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;html&gt;
      &lt;head&gt;
          &lt;meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"&gt;
          &lt;title&gt;Insert title here&lt;/title&gt;
          &lt;script&gt;
              function stringGenerate(str){
                  var x = document.getElementsByTagName("input");
                  x[0].value = str;
              }
              function numberGenerate(num){
                  var x = document.getElementsByTagName("input");
                  x[1].value = num;
              }
          &lt;/script&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;%
              String num ="1234567890";
              String str = "abcdefghij";
          %&gt;
  
          &lt;input type="text" name="string" readonly="readonly"/&gt; &amp;nbsp;&amp;nbsp;
          &lt;input type="text" name="number" readonly="readonly"/&gt;&lt;br/&gt;&lt;br/&gt;
  
          &lt;input type="button" value="String Generate" onclick= "stringGenerate(&lt;%=str %&gt;)" /&gt; &amp;nbsp;&amp;nbsp;
          &lt;input type="button" value="Number Generate" onclick= "numberGenerate(&lt;%=num %&gt;)" /&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>When I click on the button with value "Number Generate",then the num variable value(1234567890) will display on the textbox(name="number") but when I click on the button with value "String Generate",then there is nothing display on the corresponding text box(name="string").Here both num and str are string type varible but why only num variable value is displayed on textbox and why not str variable value is displayed?</p>