
passing javascript values to jsp

Hi Friend,
Try the following code:
form.jsp:
<html>
<script>
function getMsg(){
var value="Hello";
window.location.replace("form.jsp?msg="+value);
}
</script>
<input type="button" onclick="getMsg();" value="Get Javascript value In JSP">
<%
String st=request.getParameter("msg");
if(st!=null){
out.println(st);
}
%>
</html>
Thanks

<html>
<script>
function getMsg(){
var value="Hello";
window.location.replace("form.jsp?msg="+value);
}
</script>
<input type="button" onclick="getMsg();" value="Get Javascript value In JSP">
<%
String st=request.getParameter("msg");
if(st!=null){
out.println(st);
}
%>
</html>
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.