I can provide two ways,

a.jsp:

<html>
<script language="javascript" type="text/javascript">
function call(){
var name = "xyz";
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="xyz";
</script>
<% String st="<script>document.writeln(v)</script>";
out.println("value="+st); %>
Advertisements
Comments
  1. Jhonny jonas says:

    Thank you for this your blog is very decent and this post is amazing

    Like

  2. Eva Angelina says:

    You have observed very interesting details! ps decent internet site.

    Like

  3. Sanam says:

    How to pass a boolen value from script and fetch it in scriplets?

    Like

  4. Azad Moulan says:

    thank u for this code. but i want to pass multiple parameter how can i?

    Like

  5. […] How do I pass JavaScript values to Scriptlet in JSP … – … ("a.jsp?name="+name); } " onclick=’call … How do I pass JavaScript values to Scriptlet in JSP … , javascript, JavaServer Pages … […]

    Like

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s