Passing variable from JSP to Javascript -


i know there questions that, can´t work, have jsp file java variable in it:

string test = "hello";

and need read value in javascript embedded in same jsp file, tried many options, not working, , security don't want pass value using url or hidden values.

any ideas of how working?

i know 1 old, worked me:

var javascriptvar="<%out.print(javastring);%>"; 

you need make sure if using external js file (out of jsp file), above line has before "include" script tag. example jsp file:

var javascriptvar="<%out.print(javastring);%>"; <script src="some_location/test.js"></script> 

Comments

Popular posts from this blog

How to mention the localhost in android -

php - Calling a template part from a post -

c# - String.format() DateTime With Arabic culture -