我在应用会话时遇到了麻烦。jsp会话重定向
index.jsp具有简单的登录表单,当提交到一个创建会话并重定向到admin_home.jsp页面的servlet时,这里的一切都很顺利。
但我想,当用户直接想去admin_home.jsp,他会重定向到的index.jsp page.Here的问题是:
admin_home.jsp
<body>
<%
session=request.getSession(false);
if(session.getAttribute("User_ID")==null)
{
response.sendRedirect("index.jsp");
}
%>
<jsp:include page="header.jsp"></jsp:include>
<div>
<div id="left">
<div id="photo">
<img alt="" src="images/users_image/<%out.println(session.getAttribute("User_ID").toString().concat(".jpg"));%>" />
</div>
</div>
</div>
</body>
登录的servlet在设置值USER_ID会话....
因此,当用户试图访问admin_home.jsp直接,他应该重定向到index.jsp页面... 什么是错在我的代码....
你得到任何错误;或者只是重新指导不会发生? – Deepak
我得到nullpointerexception在行“/> –