我想在 CheckForLogin Servlet 中创建会话并在所有 JSP 页面中使用它(用于检查)。应该在我的 JSP 页面中写什么,而不是在 Sevlet 中写……。如何在 Servlet 中定义会话?
public void service(ServletRequest request,
ServletResponse response) throws ServletException, IOException {
String email = request.getParameter("email");
String password = request.getParameter("password");
if (email.equals("") || password.equals("") || email == null || password == null) {
request.getRequestDispatcher("Error.jsp?err=enterdata").forward(request,response);
} else {
UserBl userBl = new UserBl();
if (userBl.checkUser(email, password)) {
..........................
request.getRequestDispatcher("Home.jsp").forward(request, response);
} else {
request.getRequestDispatcher("Error.jsp?err=nulluser").forward(request, response);
}
}
}