您好,欢迎访问一九零五行业门户网

JSP和Struts解决用户退出问题_MySQL

struts
在一个有密码保护的web应用中,正确处理用户退出过程并不仅仅只需调用httpsession的invalidate()方法。现在大部分浏览器上都有后退和前进按钮,允许用户后退或前进到一个页面。如果在用户在退出一个web应用后按了后退按钮浏览器把缓存中的页面呈现给用户,这会使用户产生疑惑,他们会开始担心他们的个人数据是否安全。许多web应用强迫用户退出时关闭整个浏览器,这样,用户就无法点击后退按钮了。还有一些使用javascript,但在某些客户端浏览器这却不一定起作用。这些解决方案都很笨拙且不能保证在任一情况下100%有效,同时,它也要求用户有一定的操作经验。
//...
//initialize requestdispatcher object; set forward to home page by default
requestdispatcher rd = request.getrequestdispatcher(home.jsp);
rd.forward(request, response);
}
//...
//allow the rest of the dynamic content in this jsp to be served to the browser
//...
response.setheader(pragma,no-cache); //http 1.0 backward compatibility
string username = (string) session.getattribute(user);
if (null == username) {
 request.setattribute(error, session has ended. please login.);
 requestdispatcher rd = request.getrequestdispatcher(login.jsp);
 rd.forward(request, response);
}
//...
rd = request.getrequestdispatcher(login.jsp); }
 }
 else { //password does not match, i.e., invalid user password
request.setattribute(error, invalid password.);
rd = request.getrequestdispatcher(login.jsp);
 }
 //...
 rd.forward(request, response);
//...
this.saveerrors(request, errors);
 return mapping.findforward(sessionended);
}
return executeaction(mapping, form, request, response);
 }
其它类似信息

推荐信息