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.
JavaScript pass arguments
How to pass variable from one class to another in java
How many ways we can pass the variable through the navigation between the pages?
onclick pass variable - JSP-Servlet
ModuleNotFoundError: No module named 'jspp'
ModuleNotFoundError: No module named 'JSPy'
javascript variable value insertion in DB
how to pass form values from javascript of html page to jsp page
JavaScript display variable in alert
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?
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..
Getting Json data from servlet to javascript variable
convert javascript var to java variable - JSP-Servlet
Can I pass a
how to write jsps and databasetables,umldiagrams in fuelmanagement system project
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.
Html/JavaScript code - JSP-Servlet
how to inherit static variable
how to define variable in node js
how to define variable in node js
unable to get value returned from javascript variable in page
How to create variable in TensorFlow?
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
Passing variable
PHP Variable Functions
PASS value
How to define a constant variable in Java?
Protect JSPs from direct access
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.

Ads