具体的应用一般都是这样:
<script>
function do(){
var a='<%=session.getAttribute("userName")%>'
//或者用var a="${sessionScope.userName}"
}
</script>
此方法在静态页面中不可用,在javascript文件下不可用,用于jsp页面中嵌套的脚本中。
在jsp中使用js中的设置属性,进而获得session保存的属性值,实例如下:session设置:
session.setAttribute("username",username)
session.setAttribute("password",password)
session获取:
username=session.getAttribute("username")
password=session.getAttribute("password")