我已经为jsp表中的每一行生成了动态删除链接。当我单击该链接时,它应该删除关联的行,它可以正常工作。但是,一旦注销,它就不应删除该行。.我复制了删除链接并注销。.现在,如果我运行该链接,它将重定向到“登录”页面,如果再次登录,则在表中查看了学生。该特定行。
为什么即使删除了属性并使会话无效,它为何仍然可以访问servlet?
已生成删除学生的链接。
http://localhost:8080/feeManagement/Delete_Action_Student?delete=67657
这是我的DeleteStudent,注销servlet。
@WebServlet("/Delete_Action_Student")
public class Delete_Action_Student extends HttpServlet {
private static final long serialVersionUID = 1L;
public Delete_Action_Student() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
if (request.getAttribute("Accemail") != "") {
String id = request.getParameter("delete");
try {
if (StudentDAOimpl.removeStudent(id)) {
request.setAttribute("msg", "deleted successfully");
getServletContext().getRequestDispatcher("/Delete_Student").forward(request, response);
} else {
request.setAttribute("msg", "failed to remove");
getServletContext().getRequestDispatcher("/Delete_Student").forward(request, response);
}
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
response.sendRedirect("/loginjsp.jsp");
}
}
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
}
}
退出代码段。
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
session.removeAttribute("Accemail");
session.invalidate();
response.sendRedirect("loginjsp.jsp");
}
答案 0 :(得分:0)
这是浏览器的行为,用于存储您来自登录页面的URL。因此,成功登录后,它将重定向到该URL。
成功登录后,如果您想始终登陆首页,则可以使用过滤器进行操作。