I have a variable defined in my.jsp file.
<%String myvarible = "testing";%>
my.js is imported into my.jsp (just before the end of body). I try to access the myvarible in my.js. I tries several methods on the internet. But failed.
Any help is welcome
Generally, I put the assign variable on some data-attribute
of some html tag. Then I can access it on my js
file.
my.jsp
<div class="foo" data-jsp-variable="<%= myvariable %>"></div>
my.js
var bar = $('.foo').data('jsp-variable')