I’ve a javascript variable which i need to pass as a parameter to the included file.
Ex:
var var1 = “test”;
Now i need to pass this ‘var1’ to an include file like this
<%@include file=”text.jsp?param1=” + var1 %>
Will this work ? Help me out.
Or, is there any other way around without submitting the form, I need to pass this variable data to that included file which is presented in the same jsp.
No, this can’t work, because the include will be parsed on the server side, long before the javascript var is available.
Instead, you need to add a request parameter to the page url: