How can I assign the value of a javascript variable to a variable declared in jsp scriplet? Is it possible?
We are providing you two ways:
1)a.jsp:
<html> <script language="javascript" type="text/javascript"> function call(){ var name = "roseindia"; window.location.replace("a.jsp?name="+name); } </script> <input type="button" value="Get" onclick='call()'> <% String name=request.getParameter("name"); if(name!=null){ out.println(name); } %> </html>
2)b.jsp:
<script> var v="Roseindia"; </script> <% String st="<script>document.writeln(v)</script>"; out.println("value="+st); %>
Ads