How to pass javascript variable in Scriplet of JSP?

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); %>









Related Tutorials/Questions & Answers:
How to pass javascript variable in Scriplet of JSP?
How do you pass a variable by value?
Advertisements
how to assign javascript variable value to a jsp variable
how to value of one variable pass in other variable in revetse order
JSP Variable in Javascript
how to pass class variable to another class
JSP1
JSP2
you pass a variable by value.
How to pass variable from one class to another in java
JavaScript pass arguments
How many ways we can pass the variable through the navigation between the pages?
onclick pass variable - JSP-Servlet
how to pass form values from javascript of html page to jsp page
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
how to call the array variable in scriptlet from javascript function
javascript variable value insertion in DB
JavaScript display variable in alert
how to pass variable from simple java main class(not servlet) to the jsp page?
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file
php variable in javascript
passing value fron script to scriplet - JSP-Servlet
Passing a java property to a javascript variable
i want to pass Javascript value to JSP scriptlet..
how to write jsps and databasetables,umldiagrams in fuelmanagement system project
Getting Json data from servlet to javascript variable
convert javascript var to java variable - JSP-Servlet
Can I pass a
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 inherit static variable
how to define variable in node js
how to define variable in node js
Html/JavaScript code - JSP-Servlet
How to create variable in TensorFlow?
unable to get value returned from javascript variable in page
how to pass the parameter in callable statement
How to pass value of a link to a textfield
how to pass command line arguments in ant
How to define a constant variable in Java?
how many max. arguments we pass to the any function ? how many max. arguments we pass to the any function ?
How to pass an arraylist from servlet to jsp?
How to pass multiple values from a servlet to JSP?
[JSP] How to pass back ID to previous page.
Passing variable
How to comment javascript code?
How to create arrays in JavaScript?
How to define variable in Velocity

Ads