我想在我的项目中添加会话,当用户根据需要注销时,我在logout javascript函数中将会话属性设为null,该函数位于jsp文件的顶部。但是一旦我登录系统并刷新页面,会话就会变为空。这是我的功能。
function logoutFunction() {
var txt;
if (confirm("Need to Logout!") == true) {
<% session.setAttribute("Name",null); %>
document.location.href = 'Logout_Con';
location = 'index.jsp';
} else {
location = 'welcome_page.jsp';
}
document.getElementById("demo").innerHTML = txt;
}
这是错的吗?:(
答案 0 :(得分:2)
您无法在Javascript中添加Java代码。 Java代码之前执行。
您需要提交注销参数作为输入名称注销,其值为Y,然后将其检查为:
{{1}}