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 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
how to pass class variable to another class
JSP Variable in Javascript
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?
how to pass form values from javascript of html page to jsp page
how to create own tld and use it in jspx file
how to create own tld and use it in jspx file
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?
onclick pass variable - JSP-Servlet
javascript variable value insertion in DB
JavaScript display variable in alert
how to write jsps and databasetables,umldiagrams in fuelmanagement system project
php variable in javascript
passing value fron script to scriplet - JSP-Servlet
how to inherit static variable
Can I pass a
i want to pass Javascript value to JSP scriptlet..
Getting Json data from servlet to javascript variable
Passing a java property to a javascript variable
convert javascript var to java variable - JSP-Servlet
pass a variable(friends name) through a hyperlink in to another jsp.
pass a variable(friends name) through a hyperlink in to another jsp.

Ads