<%
if(session == null) {
System.out.println("Expire");
response.sendRedirect("/login.jsp");
}else{
System.out.println("Not Expire");
}
%>
<%
HttpSession sess = request.getSession(false);
String email = sess.getAttribute("email").toString();
Connection conn = Database.getConnection();
Statement st = conn.createStatement();
String sql = "select * from login where email = '" + email + "' ";
ResultSet rs = st.executeQuery(sql);
%>
当会话过期时,我尝试重定向login.jsp页面。 但是我在“String email = sesss.getAttribute(”email“)。toString();”中出现了geeting错误。如何在会话过期后重定向jsp页面?
所以任何人都请帮我解决这个错误。
基本上我想在会话过期时重定向到login.jsp页面。
什么是错误? –
你需要1)把整个地段放在'if'或2)'return'中。或者3)永远不会再使用脚本 - 他们十年来一直是非常糟糕的练习;没有人应该使用它们。 –
@BoristheSpider我和你在一起。 3,特别是数据库连接的事情让我不寒而栗。 – Thomas