I simply need to refer to a variable from a Java class in my js file, but I am not able to do it. Here is what I have:
public class MyClass.java{
public final static String JAVA_VARIABLE = "abc";
}
testJsp
has script.js
included
I need to declare the variable x, from the java file, something like below:
script.js
:
function this_is_called(){
//The below is not working
var x = '<%=MyClass.JAVA_VARIABLE %>';
}
Is there some way in which I can refer to the variable declared in MyClass.java
from script.js
?