Tuesday, February 5, 2013

JSP Variable Accessing in JavaScript


alert("${variable}");
or
alert("<%=var%>");
or full example
<html> 
<head>
<script language="javascript"> 
function access(){ 
<% String str="Hello World"; %>
var s="<%=str%>"; 
alert(s); 
} 
</script> 
</head> 
<body onload="access()"> 
</body> 
</html>

No comments:

Post a Comment