title: getting error while passing value from javascript to scriplet in jsp
body: <p>I have a requirement where i need to pass a value from Javascript to a Scriplet in a JSP. i am aware that javascript is executed on client side and jsp on the server side.i have searched online and googled a lot but till now i am not able to find a solution that i am looking for. The JSP code is as below. both javascript and scriplet are in same jsp.</p>
  
  <pre><code> &lt;script type="text/javascript"&gt;
     var strUrl = window.location.href;
     var aps = strUrl.toLowerCase().indexOf("values");
     var modifiedString = strUrl.substring(aps+8);
     var v = strUrl.indexOf(modifiedString);
     document.write(v);
  &lt;/script&gt;
   &lt;%
      String st="&lt;script&gt;document.writeln(v)&lt;/script&gt;";
      out.println("-----"+st);
      int pareseValue = Integer.parseInt(st);
      if(st.equals("0")){
        out.println("test");
       %&gt;                     
  
     &lt;h1&gt;&lt;div class="xyz"&gt;
       &lt;fmt:message&gt;header.txt&lt;/fmt:message&gt;
     &lt;/div&gt;&lt;/h1&gt;                              
  
     &lt;%
       }else{
     %&gt;           
  
      &lt;div class="pqr"&gt;
          &lt;fmt:message&gt;header1.txt&lt;/fmt:message&gt;
     &lt;/div&gt;
     &lt;%
      }
     %&gt;
  </code></pre>
  
  <p>In the above code i am trying to pass a value from Javascript to a scriplet.
  But i am getting a NumberFormatException when i try to parse that string and convert to int. looks like the variable st is not of a string type.</p>
  
  <pre><code>    String st="&lt;script&gt;document.writeln(v)&lt;/script&gt;";
      out.println("-----"+st);
      int pareseValue = Integer.parseInt(st)
  </code></pre>
  
  <p>Can you please let me know what is the problem with the above code and how can i resolve the problem that i am facing now. </p>
  
  <p>Thanks
  Vikeng</p>