我正在使用 servlet 制作我的网站并且在发布会话时遇到问题,请检查并找出错误:
login.java :
ResultSet res=smt.executeQuery("Select * from admin where name='"+user+"' and password='"+password+"'");
while(res.next())
{
String name=res.getString("name");
String pwd=res.getString("password");
if(category.equals("Admin"))
{
if(name.equals(user) && pwd.equals(password))
{
ServletContext context=request.getServletContext();
context.setAttribute("name", name);
HttpSession session=request.getSession();
session.setAttribute("name", name);
RequestDispatcher view=request.getRequestDispatcher("welcome_admin.jsp");
view.forward(request, response);
}
else
{
response.sendRedirect("index.jsp");
}
}
logout.jsp 是:
<body>
<%
session.removeAttribute("name");
session.invalidate();
%>
<b>
<%
RequestDispatcher rd=request.getRequestDispatcher("index.jsp");
rd.include(request, response);
%>
</b >
</body>
但是会话没有被释放,如果我点击后退按钮,它会再次将我重定向到页面!有人请帮帮我!