title: how to pass java variable inside javascript function?
body: <p>javascript code:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
  function submitform(){
      //  alert("inside submit");
      &lt;% String username1=(String)session.getAttribute("UserName");
  
      if(username1 == null || username1.equals("undefined")){%&gt;
          alert("please login to submit");
      &lt;% }else{ %&gt;
          //alert("In Submit form");
  
          var frm=document.getElementById("myForm");
          frm.action="Electionservlet?formidentity=editYPName&amp;Username="+&lt;%=username1%&gt;;
          //alert("before submit");
          frm.submit(); 
  
      &lt;%}%&gt;
  }
  
  &lt;/script&gt;
  </code></pre>
  
  <p>when i click on the submit button the abobe function('submitform') is called.
  so what i want here is how can i pass a java variable(username1) through javascript function and get that value inside my servlet??? </p>