Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa JavaScriptQuestions How to pass javascript variable in Scriplet of JSP?
Login         

View Questions and Answers by Category

Advertisements


 
Have Programming Question? Ask it here!
 
 
 


Paritosh Das
How to pass javascript variable in Scriplet of JSP?
1 Answer(s)      3 years and 7 months ago
Posted in : JavaScript Questions


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


Advertisement
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:
Advertisements
 

 

 

DMCA.com