try this:
<%@ page contentType="text/html;charset=windows-1252"%>
<%String sampleStr="Hello World";%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Hello World</title>
</head>
<body>
<script language="javascript">
var x = "<%=sampleStr%>";
alert(x);
</script>
</body>
</html>
> hi,
>
> i have a variable( string) in jsp. i want to pass
> that to my javascript. i did like
>
> var x = <%=jspvar%>
> but it is not working. what is the possible way?
> Thanks.
var x = '<%=jspvar%>' is working
Thanks