Reputation: 670
Hi i am giving a get request from a jsp page as shown below:
<c:forEach items="${empNameInfo.empName}" var="empNameDetail">
<a href="${contextPath}/empValues?empName=${empNameDetail.eName}& amp;empNo=${empNameDetail.eNo}">Emp Details </a></c:forEach>
And its working fine. But now i want to use it in java script so that i can refresh a particluar of other page (i.e. A.jsp having above code but from here i want to refresh the of B.jsp) so how i can give same kind of request in java script so that i can use load method and change a particular content. i mean how i can get ${empNameDetail.eName}
${empNameDetail.eNo}
in javascript.
or is their any other way to do the same pls let me know
thanks in advance
Upvotes: 0
Views: 138
Reputation: 1147
<script>
function myFunction(name,no){
alert(name+" "+no);
}
</script>
<c:forEach items="${empNameInfo.empName}" var="empNameDetail">
<a href="${contextPath}/empValues?mpName=${empNameDetail.eName}&empNo=${empNameDetail.eNo}"
onclick="myFunction('${empNameDetail.eName}','${empNameDetail.eNo}')">
Emp Details </a>
</c:forEach>
Or
You can directly use JSTL
in your java-script
code
<script>
<c:forEach items="${empNameInfo.empName}" var="empNameDetail">
var name = "<c:out value='${empNameDetail.eName}'/>" ;
alert(name);
</c:forEach>
</script>
Upvotes: 1