使用过滤器来检测session失效
来源:互联网 发布:在mac上安装jmeter 编辑:程序博客网 时间:2024/04/30 01:25
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain)
throws IOException, ServletException {
if (debug) {
log("SessionTimeoutFilter:doFilter()");
}
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
doBeforeProcessing(request, response);
HttpSession session = req.getSession();
//用户超时或没有登陆时跳转到登陆页面
logger.debug("before doFilter****");
String uri = req.getRequestURI();
if (uri.indexOf("sessiontimeout")==-1&&uri.indexOf("SysConfig")==-1&&(session.getAttribute("UserName") == null || session.isNew())) {
resp.sendRedirect(req.getContextPath()+"/sessiontimeout.jsp");
//resp.sendRedirect(req.getContextPath()+"/sessiontimeout.jsp"); 不能使用相对路径,不同的页面过来,相对路径会不同
return;
}
Throwable problem = null;
try {
chain.doFilter(request, response);
} catch (Throwable t) {
// If an exception is thrown somewhere down the filter chain,
// we still want to execute our after processing, and then
// rethrow the problem after that.
problem = t;
t.printStackTrace();
}
logger.debug("after doFilter****");
doAfterProcessing(request, response);
// If there was a problem, we want to rethrow it if it is
// a known type, otherwise log it.
if (problem != null) {
if (problem instanceof ServletException) {
throw (ServletException) problem;
}
if (problem instanceof IOException) {
throw (IOException) problem;
}
sendProcessingError(problem, response);
}
}
FilterChain chain)
throws IOException, ServletException {
if (debug) {
log("SessionTimeoutFilter:doFilter()");
}
HttpServletRequest req = (HttpServletRequest) request;
HttpServletResponse resp = (HttpServletResponse) response;
doBeforeProcessing(request, response);
HttpSession session = req.getSession();
//用户超时或没有登陆时跳转到登陆页面
logger.debug("before doFilter****");
String uri = req.getRequestURI();
if (uri.indexOf("sessiontimeout")==-1&&uri.indexOf("SysConfig")==-1&&(session.getAttribute("UserName") == null || session.isNew())) {
resp.sendRedirect(req.getContextPath()+"/sessiontimeout.jsp");
//resp.sendRedirect(req.getContextPath()+"/sessiontimeout.jsp"); 不能使用相对路径,不同的页面过来,相对路径会不同
return;
}
Throwable problem = null;
try {
chain.doFilter(request, response);
} catch (Throwable t) {
// If an exception is thrown somewhere down the filter chain,
// we still want to execute our after processing, and then
// rethrow the problem after that.
problem = t;
t.printStackTrace();
}
logger.debug("after doFilter****");
doAfterProcessing(request, response);
// If there was a problem, we want to rethrow it if it is
// a known type, otherwise log it.
if (problem != null) {
if (problem instanceof ServletException) {
throw (ServletException) problem;
}
if (problem instanceof IOException) {
throw (IOException) problem;
}
sendProcessingError(problem, response);
}
}
0 0
- 使用过滤器来检测session失效
- 使用过滤器处理Session失效的问题
- java web工程,过滤器判断session失效
- java web工程,过滤器判断session失效
- 配置struts2过滤器 session失效跳转到登陆页面
- session失效,过滤器中frame框架页面跳转
- 过滤器面对ajax访问遇到Session失效问题
- filter过滤器,处理登录session长时失效问题
- Struts2--针对session使用过滤器
- 使用过滤器实现判断session
- mvc通过添加属性来判断session是否失效
- 使用Iframe标签session失效异常
- session失效
- 利用过滤器来实现session超时,和权限管理
- Session过滤器
- session过滤器
- 使用过滤器来解决中文乱码
- 使用EncodingFilter过滤器来完成统一编码
- HBase写数据过程
- CString 如何转化为 char* ?
- 暂停更新博客,请谅解!
- linux0.11调试
- effective c++ 之代替#define
- 使用过滤器来检测session失效
- Android平台,C/C++代码内存对齐问题(signal SIGBUS Error)
- JAVA小练习-排序算法
- 读书笔记(Linux入门)
- Win7 wifi热点设置
- Terracotta 分布式缓存机制深入
- osmdroid基础教程(1)
- SharePoint2013 以其他用户登录和修改AD域用户密码 功能
- HDOJ 1425 sort hash(雾)