反过来从jsp中调用javascript的变量不行!<%
int strI=10;
%>
<script language="javascript">
<!-- function show<%=strI%>()
{
var si=1;
var text="";
alert(<%=strI%);
}//--
</script>
int strI=10;
%>
<script language="javascript">
<!-- function show<%=strI%>()
{
var si=1;
var text="";
alert(<%=strI%);
}//--
</script>
var timer = null;
function checkForRefresh() {
if (top.location.pathname != "<%=request.getContextPath()%>/logon.jsp" &&
top.location.pathname != "<%=request.getContextPath()%>/logoff.do") {
top.location = "<%=request.getContextPath()%>/logon.jsp";
setTimeout("checkForRefresh()",100);
}
}
</script>jsp中不需要使用javascript的变量的
js run at client side
是不可能互相调用的楼上的只是用jsp动态生成js罢了
out.print("<script language="javascript">var a='haha'</script>");js中就可以使用变量a了
相互调用方法是不可能了,至于值,可以通过某些方式传递
比如jsp到javascript,可以把变量写在<%%>里面,变量的值就会被传递过去
从javascript到jsp,通过表单提交或者QueryString传递到服务端,jsp通过request对象的getParameter方法就可以取得
使用soap 走web service ,通过xml来实现直接调用是不可能的,两者不在同一段运行。