我的问题具体是:我做了一个小型管理系统 用的是jsp structs 框架 ,问题就是我做了一个网页过滤,想让它实现退出后:以前访问过的页面都不能通过任何方法再访问到 除了重新登陆。
问题就出现在这:比如我我的登陆页面是index.jsp 我登陆 提交数据到check.do 转到下一页面usr.jsp显示信息,我在usr.jsp页面退出后。在地址栏输入http://localhost:8888/ComputerTime/usr.jsp 它跳回到了登陆页面,可是你输入http://localhost:8888/ComputerTime/check.do 他还能回到刚才的usr.jsp页面
我的xml中关于网页过滤配置如下:
<filter>
<filter-name>SessionFilter</filter-name>
<filter-class>MyPack.SessionFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SessionFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
SessionFilter.java内容如下:
public class SessionFilter extends HttpServlet implements Filter {
public void init(FilterConfig arg0) throws ServletException {
// TODO 自动生成方法存根
}
public void doFilter(ServletRequest arg0, ServletResponse arg1,
FilterChain arg2) throws IOException, ServletException {
// TODO 自动生成方法存根
//检查session中的标志
// protectpage/welcome.jsp
System.out.println("执行Session过滤");
HttpSession session = ((HttpServletRequest) arg0).getSession();
if(session.getAttribute("usr")==null){ //没有登录
//((HttpServletResponse)arg1).sendRedirect("/index.jsp");
arg0.getRequestDispatcher("index.jsp").forward(arg0,arg1) ;
}else{//已经登录
arg2.doFilter(arg0,arg1);
}
}
/**
* Constructor of the object.
*/
public SessionFilter() {
super();
}
/**
* Destruction of the servlet. <br>
*/
public void destroy() {
super.destroy(); // Just puts "destroy" string in log
// Put your code here
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the GET method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out
.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">");
out.println("<HTML>");
out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>");
out.println(" <BODY>");
out.print(" This is ");
out.print(this.getClass());
out.println(", using the POST method");
out.println(" </BODY>");
out.println("</HTML>");
out.flush();
out.close();
}
public void init() throws ServletException {
}
}
高手指导下 哪块出问题了
不懂,建议去java社区问问,这里的人大多都是搞微软平台的!
学习....