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

 
 


Paritosh Das
How to pass javascript variable in Scriplet of JSP?
1 Answer(s)      2 years and a month 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?

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.