0

I need to define a java String in my jsp page thanks to a javascript variable, I know we can do the opposite with :

<% String str = "ok"; %>
var test="<%= str %>";

I wanted to know if something like this was possible :

var test="ok";
<% String str = %> test <% ; %>

I tried and it didn't worked but is there a way to achieve what I want ?

Uri Agassi
  • 36,848
  • 14
  • 76
  • 93
Simon M.
  • 2,244
  • 3
  • 17
  • 34
  • 2
    You can't do that with any server-side language... If you want to get a JavaScript variable value you'll need to send it using AJAX and receive using Java Web services............. – Matías Fidemraizer Feb 09 '16 at 10:27
  • 2
    Related here http://stackoverflow.com/questions/8268356/assign-javascript-variable-to-java-variable-in-jsp – Revive Feb 09 '16 at 10:28

0 Answers0