java - How to access javascript variable in a jsp page -


i want access javascript code in jsp file. have included javascript file in jsp page.

javascript file abc.js has following line of code:

var dynamicdiv = 'your leave approved'; 

and jsp file aaa.jsp has

<script src="abc.js"> </script>     <% string st = "<script> dynamicdiv </script>"; out.println(" value = " + st); %> 

javascript variable on client side, jsp variables on server side, can't access javascript variables in jsp.

you can store values in hidden field somthing this

clinet side:

<script type="text/javascript"> var element = document.getelementbyid("myinput"); element.value = "some value here"; </script> <form action="yourfile.jsp" method="post"> <input id="myinput" type="hidden" value="" /> <input type="submit" /> </form> 

server side(yourfile.jsp):

<% if (request.getparameter("myinput") != null) { %>  value: <%=request.getparameter("myinput")%> <%    }  %> 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -