Facebook Twitter LinkedIn RSS
 
 
Home » JSP » How to pass a variable from JSP to JavaScript

How to pass a variable from JSP to JavaScript

Now I am going to explain how we can pass a JSP variable to JavaScript code. For example I have the JSP variable <%= jspParameter %>, which I want to be accessed by my JavaScript code. In the Javascript code I will define a new js variable and I will pass the JSP variable:

var jsVar = '<%= jspParameter %>';

Now I can access the jspParameter in the JS code through the jsVar variable.

 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>