How to pass javascript variable in Scriplet of JSP?

Ads
 

How to pass javascript variable in Scriplet of JSP?

How can I assign the value of a javascript variable to a variable declared in jsp scriplet? Is it possible?

View Answers

April 26, 2011 at 11:23 AM

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









Related Tutorials/Questions & Answers:
How to pass javascript variable in Scriplet of JSP?
how to assign javascript variable value to a jsp variable
Advertisements
how to value of one variable pass in other variable in revetse order
JSP Variable in Javascript
How to pass variable from one class to another in java
you pass a variable by value.
JavaScript pass arguments
JSP1
JSP2
how to call the array variable in scriptlet from javascript function
how to pass variable from simple java main class(not servlet) to the jsp page?
JavaScript display variable in alert
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
how to write jsps and databasetables,umldiagrams in fuelmanagement system project
how to inherit static variable
Passing a java property to a javascript variable
how to define variable in node js
how to define variable in node js
i want to pass Javascript value to JSP scriptlet..
Getting Json data from servlet to javascript variable
Can I pass a
How to create variable in TensorFlow?
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.
how to pass the parameter in callable statement
How to define a constant variable in Java?
how to pass command line arguments in ant
unable to get value returned from javascript variable in page

Ads