Is there a way that I can pass a JSP variable value to an external Javascript file by using only Javascript and JSP. Something like:
JSP
String str = "Hello";
external.js
//not working var str = "<%=str%>";
Thanks.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you think that the java script is written inside the JSP then its possible.
But you are providing the JS file separately then you can make a global variable and that variable will be available everywhere.