Home> php教程> PHP开发> body text

How to solve the problem of session expiration in JSP by jumping to the login page and jumping out of the iframe

高洛峰
Release: 2017-01-07 09:41:54
Original
2095 people have browsed it

When the session expires, you can use filters to set up redirect pages

public class ActionFilter extends HttpServlet implements Filter { private FilterConfig filterConfig; public void init(FilterConfig config) { this.filterConfig = config; } public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws ServletException, IOException { HttpServletRequest req = (HttpServletRequest) servletRequest; servletRequest.setCharacterEncoding(“UTF-8″); HttpServletResponse res = (HttpServletResponse) servletResponse; String url = req.getRequestURI(); SysUserVOImpl user = (SysUserVOImpl) req.getSession().getAttribute(“SysUser”); if (null == user) { if (!COMMON.isEmpty(url) && (url.endsWith(“newestlogin.jsp”) || url.endsWith(“UserLoginAction.jsp”) || url.endsWith(“login.jsp”) || url.endsWith(“loginAction.do”))) { filterChain.doFilter(servletRequest, servletResponse); } else { req.getRequestDispatcher(“/newestlogin.jsp”).forward(req, res); } } else { filterChain.doFilter(servletRequest, servletResponse); } }
Copy after login
, but this will not allow you to jump out of iframes and other frames.
Can be solved with javaScript

Add the following code between the page you want to control the jump to, such as login.jsp betweenand

:

Copy after login

JS Refresh Frame Script Statement

//如何刷新包含该框架的页面用  //子窗口刷新父窗口  ( 或 刷新 ) //如何刷新另一个框架的页面用  如果想关闭窗口时刷新或者想开窗时刷新的话,在中调用以下语句即可。  开窗时刷新  关闭时刷新 
Copy after login

For more related articles on how to solve the problem of session expiration and jump to the login page and jump out of the iframe in Jsp, please pay attention to the PHP Chinese website!


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template
    About us Disclaimer Sitemap
    php.cn:Public welfare online PHP training,Help PHP learners grow quickly!