2

I am trying to print the java script variable to jsp page like

<script> var v="Javed";</script><% String jspvar="<script>document.writeln(v);</script>";out.println("jspvar=======>>>>>>"+jspvar); 

but in the output i am getting "document.writeln(v)". what should i do so get the value of variable . thank you

4

1 回答 1

1

Javascript 在客户端运行,jsp 代码在服务器上运行。所以当jsp代码运行的时候,v还没有被初始化。

你为什么不这样做:

<script> 
    var v = "Javed";
    document.writeln(v);
</script>
于 2013-05-24T18:44:21.560 回答