Get the App
SLTechnology News&Howtos  ›  Development  › 

How to deal with the problem of web login timeout giving a prompt to jump to the login page

Shulou Source: shulou.com Published: 2022-06-03 13:34:32 09月16日 Update

This article shows you how to deal with the problem of web login timeout giving hints to jump to the login page, the content is concise and easy to understand, it will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

1. For general page login timeout verification, you can use the filter filter, as follows:

Package com.lg.filter;import java.io.IOException;import javax.servlet.Filter;import javax.servlet.FilterChain;import javax.servlet.FilterConfig;import javax.servlet.ServletException;import javax.servlet.ServletRequest;import javax.servlet.ServletResponse;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpServletResponse;import com.lg.func.MyFunc;public class LoginFilter implements Filter {public void destroy () {} public void doFilter (ServletRequest request, ServletResponse response,FilterChain chain) throws ServletException, IOException {HttpServletRequest request1= (HttpServletRequest) request;HttpServletResponse response1= (HttpServletResponse) response Chain.doFilter (request, response); / / release. Take it to the next chain or target resource String url=request1.getServletPath (); System.out.println ("before Demo1 filtering" + url); MyFunc myFunc = new MyFunc (request1,response1); System.out.println ("before Demo1 filtering" + url.startsWith ("/ index/")); if (myFunc.checkLogin2 () &! url.startsWith ("/ index/")) {response1.sendRedirect ("/ index_login.html");} System.out.println ("after Demo1 filtering") } public void init (FilterConfig arg0) throws ServletException {/ / TODO Auto-generated method stubSystem.out.println ("= init= filtered");}}

Web.xml configuration

Demo1Filtercom.lg.filter.LoginFilterDemo1Filter*.jsp

II. Ajax submission

Submit page, my page prompts pop-up frame to use asyncBox, can be changed to other jump

< pad > < Abstrcat > < pad > < pad >-1) {alert (success);} else {alert (failure) is returned to the login page if (checkLogin2 (msg)) {var obj=eval ('('+ msg+')'); if (obj.result.indexOf ("suc") >-1) {if (msg.indexOf ("DOCTYPE") >-1) {checkLogin (); return false;}} return true;} function checkLogin () {if (window.top! = window.self) {top.asyncbox.alert ('login timeout', 'prompt', function (action) {top.location.href='/login.jsp') });} else {asyncbox.alert ('login timed out, please login again', 'prompt', function (action) {_ window.location.href='/login.jsp';});}}

Background:

1. Before processing the data

If (checkLogin ()) return; / / check login, session expired or not logged in, automatically redirect public boolean checkLogin () throws IOException {boolean result = false;String html = ""; NativeObject u = SessionMng.getCurrentUser (request); / / verify login timeout if (u = = null) {html = "\ n" + "\ n" + "checkLogin ();\ n"; response.getWriter (). Println (html); result = true;} return result;}

Third, import excel asynchronously

Import excel function with AjaxUpload.js

The front-end submission page refers to the above

Background processing page:

If (! isLogin ()) {response.getWriter () .print ("DOCTYPE"); return;} / whether to log in to public boolean isLogin () {NativeObject u = SessionMng.getCurrentUser (request); if (u! = null) {return true;} else {return false;}}

four. Export excel files with window.open

The background is the same.

Front-end export page

Function export_excel () {$.ajax ({type: "post", url: "/ admin/inc/checkLogin.jsp", async:false,// synchronization success:function (msg) {if (checkLogin2 (msg)) {window.open ("perfm_excel.jsp?" + $('# Form1'). Serialize ());}}); login.jsp above is how to deal with the problem of web login timeout prompting to jump to the login page, have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Tags: Login page prompt background question content front end skills knowledge synchronization processing concise successful concise functional that is data files articles more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux OPPO Reno Shulou Information NVidia Huawei